/*
* sound/arm/omap/omap-alsa-twl4030.c
*
* Codec driver for TWL4030 for OMAP processors
*
* Copyright (C) 2007 Texas Instruments, Inc.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* History:
* -------
* 2006-01-18 Nishanth Menon - Created
* 2006-09-15 Jian Zhang - Ported to ALSA
* 2007-04-16 Leonides Martinez - Added ALSA controls
*/
#define XXX_VER "0.1"
#ifdef MATRIX_DEBUG
#define MATRIXPT(x...) do{ printf(x...)}while(0)
#else
#define MATRIXPT(x...) do{}while(0)
#endif
//you can use modinfo to get informations of this modules
int log_level = 1;
module_param(log_level, int, 0);
MODULE_PARM_DESC(log_level, "log_level: 0 (none), 1 (less), 2 (more), 3 (verbose)");
..........................
atomic_t open_flag;
static /*const */ struct file_operations xxx_audio_fops =
{
owner: THIS_MODULE,
read: xxx_read,
write: xxx_write,
poll: xxx_poll,
ioctl: xxx_ioctl,
open: xxx_open,
release: xxx_release,
};
static int xxx_open(struct inode *inode, struct file *file)
{
/* wait for device to become free */
if (!atomic_dec_and_test(&xxx_state.open_flag))
{
atomic_inc(&xxx_state.open_flag);
return -EBUSY; // already open
}
}
static int at6600_release(struct inode *inode, struct file *file)
{
atomic_inc(&xxx_state.open_flag);
}
static int __init init_xxx(void)
{
//only one thread can open this device
atomic_set(&xxx_state.open_flag,1);
//dynamic allocate major and minor, you can read form /proc/devices
//if a char dev
unsigned int major;
major = register_chrdev (0 ,XXX_DEV_NAME, & XXX_fops);
//if a blk dev;
major = register_blkdev(0, XXX_NAME);
}
module_init (xxx_init);
module_exit (xxx_exit);
MODULE_AUTHOR("cindy qin");
MODULE_DESCRIPTION("xxx Driver");
MODULE_LICENSE ("GPL");
MODULE_VERSION(XXX_VER);
* sound/arm/omap/omap-alsa-twl4030.c
*
* Codec driver for TWL4030 for OMAP processors
*
* Copyright (C) 2007 Texas Instruments, Inc.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* History:
* -------
* 2006-01-18 Nishanth Menon - Created
* 2006-09-15 Jian Zhang - Ported to ALSA
* 2007-04-16 Leonides Martinez - Added ALSA controls
*/
#define XXX_VER "0.1"
#ifdef MATRIX_DEBUG
#define MATRIXPT(x...) do{ printf(x...)}while(0)
#else
#define MATRIXPT(x...) do{}while(0)
#endif
//you can use modinfo to get informations of this modules
int log_level = 1;
module_param(log_level, int, 0);
MODULE_PARM_DESC(log_level, "log_level: 0 (none), 1 (less), 2 (more), 3 (verbose)");
..........................
atomic_t open_flag;
static /*const */ struct file_operations xxx_audio_fops =
{
owner: THIS_MODULE,
read: xxx_read,
write: xxx_write,
poll: xxx_poll,
ioctl: xxx_ioctl,
open: xxx_open,
release: xxx_release,
};
static int xxx_open(struct inode *inode, struct file *file)
{
/* wait for device to become free */
if (!atomic_dec_and_test(&xxx_state.open_flag))
{
atomic_inc(&xxx_state.open_flag);
return -EBUSY; // already open
}
}
static int at6600_release(struct inode *inode, struct file *file)
{
atomic_inc(&xxx_state.open_flag);
}
static int __init init_xxx(void)
{
//only one thread can open this device
atomic_set(&xxx_state.open_flag,1);
//dynamic allocate major and minor, you can read form /proc/devices
//if a char dev
unsigned int major;
major = register_chrdev (0 ,XXX_DEV_NAME, & XXX_fops);
//if a blk dev;
major = register_blkdev(0, XXX_NAME);
}
module_init (xxx_init);
module_exit (xxx_exit);
MODULE_AUTHOR("cindy qin");
MODULE_DESCRIPTION("xxx Driver");
MODULE_LICENSE ("GPL");
MODULE_VERSION(XXX_VER);