+/*
+ */
+
#include <linux/module.h>
+#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#define DEV_MAX 4
static int devnr = -1;
-MODULE_PARM(devnr,"i");
+module_param(devnr, int, 0644);
MODULE_AUTHOR("Gerd Knorr");
MODULE_LICENSE("GPL");
{
struct video_audio va;
int left,right,ret,val = 0;
- struct TVMIXER *mix = file->private_data;
+ struct TVMIXER *mix = file->private_data;
struct i2c_client *client = mix->dev;
+ void __user *argp = (void __user *)arg;
+ int __user *p = argp;
if (NULL == client)
return -ENODEV;
-
- if (cmd == SOUND_MIXER_INFO) {
- mixer_info info;
- strlcpy(info.id, "tv card", sizeof(info.id));
- strlcpy(info.name, i2c_clientname(client), sizeof(info.name));
- info.modify_counter = 42 /* FIXME */;
- if (copy_to_user((void *)arg, &info, sizeof(info)))
- return -EFAULT;
- return 0;
- }
- if (cmd == SOUND_OLD_MIXER_INFO) {
- _old_mixer_info info;
- strlcpy(info.id, "tv card", sizeof(info.id));
- strlcpy(info.name, i2c_clientname(client), sizeof(info.name));
- if (copy_to_user((void *)arg, &info, sizeof(info)))
- return -EFAULT;
- return 0;
- }
- if (cmd == OSS_GETVERSION)
- return put_user(SOUND_VERSION, (int *)arg);
+
+ if (cmd == SOUND_MIXER_INFO) {
+ mixer_info info;
+ strlcpy(info.id, "tv card", sizeof(info.id));
+ strlcpy(info.name, client->name, sizeof(info.name));
+ info.modify_counter = 42 /* FIXME */;
+ if (copy_to_user(argp, &info, sizeof(info)))
+ return -EFAULT;
+ return 0;
+ }
+ if (cmd == SOUND_OLD_MIXER_INFO) {
+ _old_mixer_info info;
+ strlcpy(info.id, "tv card", sizeof(info.id));
+ strlcpy(info.name, client->name, sizeof(info.name));
+ if (copy_to_user(argp, &info, sizeof(info)))
+ return -EFAULT;
+ return 0;
+ }
+ if (cmd == OSS_GETVERSION)
+ return put_user(SOUND_VERSION, p);
if (_SIOC_DIR(cmd) & _SIOC_WRITE)
- if (get_user(val, (int *)arg))
+ if (get_user(val, p))
return -EFAULT;
/* read state */
va.volume) / 32768;
ret = v4l_to_mix2(left,right);
break;
-
+
case MIXER_WRITE(SOUND_MIXER_BASS):
va.bass = mix_to_v4l(val);
client->driver->command(client,VIDIOCSAUDIO,&va);
default:
return -EINVAL;
}
- if (put_user(ret, (int *)arg))
+ if (put_user(ret, p))
return -EFAULT;
return 0;
}
static int tvmixer_open(struct inode *inode, struct file *file)
{
- int i, minor = iminor(inode);
- struct TVMIXER *mix = NULL;
+ int i, minor = iminor(inode);
+ struct TVMIXER *mix = NULL;
struct i2c_client *client = NULL;
for (i = 0; i < DEV_MAX; i++) {
/* lock bttv in memory while the mixer is in use */
file->private_data = mix;
-#ifndef I2C_PEC
- if (client->adapter->inc_use)
- client->adapter->inc_use(client->adapter);
-#endif
if (client->adapter->owner)
try_module_get(client->adapter->owner);
- return 0;
+ return 0;
}
static int tvmixer_release(struct inode *inode, struct file *file)
return -ENODEV;
}
-#ifndef I2C_PEC
- if (client->adapter->dec_use)
- client->adapter->dec_use(client->adapter);
-#endif
if (client->adapter->owner)
module_put(client->adapter->owner);
return 0;
}
static struct i2c_driver driver = {
-#ifdef I2C_PEC
- .owner = THIS_MODULE,
-#endif
- .name = "tv card mixer driver",
- .id = I2C_DRIVERID_TVMIXER,
-#ifdef I2C_DF_DUMMY
- .flags = I2C_DF_DUMMY,
-#else
- .flags = I2C_DF_NOTIFY,
- .detach_adapter = tvmixer_adapters,
-#endif
- .attach_adapter = tvmixer_adapters,
- .detach_client = tvmixer_clients,
+ .driver = {
+ .name = "tvmixer",
+ },
+ .id = I2C_DRIVERID_TVMIXER,
+ .detach_adapter = tvmixer_adapters,
+ .attach_adapter = tvmixer_adapters,
+ .detach_client = tvmixer_clients,
};
static struct file_operations tvmixer_fops = {
struct video_audio va;
int i,minor;
-#ifdef I2C_CLASS_TV_ANALOG
if (!(client->adapter->class & I2C_CLASS_TV_ANALOG))
return -1;
-#else
- /* TV card ??? */
- switch (client->adapter->id) {
- case I2C_ALGO_BIT | I2C_HW_SMBUS_VOODOO3:
- case I2C_ALGO_BIT | I2C_HW_B_BT848:
- case I2C_ALGO_BIT | I2C_HW_B_RIVA:
- /* ok, have a look ... */
- break;
- default:
- /* ignore that one */
- return -1;
- }
-#endif
/* unregister ?? */
for (i = 0; i < DEV_MAX; i++) {
devices[i].dev = NULL;
devices[i].minor = -1;
printk("tvmixer: %s unregistered (#1)\n",
- i2c_clientname(client));
+ client->name);
return 0;
}
}
devices[i].dev = client;
printk("tvmixer: %s (%s) registered with minor %d\n",
client->name,client->adapter->name,minor);
-
+
return 0;
}
/* ----------------------------------------------------------------------- */
-static int tvmixer_init_module(void)
+static int __init tvmixer_init_module(void)
{
int i;
-
+
for (i = 0; i < DEV_MAX; i++)
devices[i].minor = -1;
- i2c_add_driver(&driver);
- return 0;
+
+ return i2c_add_driver(&driver);
}
-static void tvmixer_cleanup_module(void)
+static void __exit tvmixer_cleanup_module(void)
{
int i;
-
+
i2c_del_driver(&driver);
for (i = 0; i < DEV_MAX; i++) {
if (devices[i].minor != -1) {
unregister_sound_mixer(devices[i].minor);
printk("tvmixer: %s unregistered (#2)\n",
- i2c_clientname(devices[i].dev));
+ devices[i].dev->name);
}
}
}