patch-2.4.22 linux-2.4.22/drivers/media/video/tvmixer.c
Next file: linux-2.4.22/drivers/message/fusion/Makefile
Previous file: linux-2.4.22/drivers/media/video/tvaudio.h
Back to the patch index
Back to the overall index
- Lines: 139
- Date:
2003-08-25 04:44:42.000000000 -0700
- Orig file:
linux-2.4.21/drivers/media/video/tvmixer.c
- Orig date:
2003-06-13 07:51:34.000000000 -0700
diff -urN linux-2.4.21/drivers/media/video/tvmixer.c linux-2.4.22/drivers/media/video/tvmixer.c
@@ -10,21 +10,18 @@
#include <linux/videodev.h>
#include <linux/init.h>
#include <linux/kdev_t.h>
-#include <asm/semaphore.h>
-
#include <linux/sound.h>
#include <linux/soundcard.h>
+
+#include <asm/semaphore.h>
#include <asm/uaccess.h>
-#include "audiochip.h"
-#include "id.h"
+# include "i2c-compat.h"
+# define strlcpy(dest,src,len) strncpy(dest,src,(len)-1)
#define DEV_MAX 4
-static int debug = 0;
static int devnr = -1;
-
-MODULE_PARM(debug,"i");
MODULE_PARM(devnr,"i");
MODULE_AUTHOR("Gerd Knorr");
@@ -88,8 +85,8 @@
if (cmd == SOUND_MIXER_INFO) {
mixer_info info;
- strncpy(info.id, "tv card", sizeof(info.id));
- strncpy(info.name, client->name, sizeof(info.name));
+ 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;
@@ -97,8 +94,8 @@
}
if (cmd == SOUND_OLD_MIXER_INFO) {
_old_mixer_info info;
- strncpy(info.id, "tv card", sizeof(info.id));
- strncpy(info.name, client->name, sizeof(info.name));
+ 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;
@@ -136,16 +133,16 @@
case MIXER_WRITE(SOUND_MIXER_VOLUME):
left = mix_to_v4l(val);
right = mix_to_v4l(val >> 8);
- va.volume = MAX(left,right);
- va.balance = (32768*MIN(left,right)) / (va.volume ? va.volume : 1);
+ va.volume = max(left,right);
+ va.balance = (32768*min(left,right)) / (va.volume ? va.volume : 1);
va.balance = (left<right) ? (65535-va.balance) : va.balance;
client->driver->command(client,VIDIOCSAUDIO,&va);
client->driver->command(client,VIDIOCGAUDIO,&va);
/* fall throuth */
case MIXER_READ(SOUND_MIXER_VOLUME):
- left = (MIN(65536 - va.balance,32768) *
+ left = (min(65536 - va.balance,32768) *
va.volume) / 32768;
- right = (MIN(va.balance,32768) *
+ right = (min(va.balance,(u16)32768) *
va.volume) / 32768;
ret = v4l_to_mix2(left,right);
break;
@@ -237,8 +234,6 @@
{
int i;
- if (debug)
- printk("tvmixer: adapter %s\n",adap->name);
for (i=0; i<I2C_CLIENT_MAX; i++) {
if (!adap->clients[i])
continue;
@@ -260,12 +255,8 @@
break;
default:
/* ignore that one */
- if (debug)
- printk("tvmixer: %s is not a tv card\n",
- client->adapter->name);
return -1;
}
- printk("tvmixer: debug: %s\n",client->name);
/* unregister ?? */
for (i = 0; i < DEV_MAX; i++) {
@@ -274,7 +265,8 @@
unregister_sound_mixer(devices[i].minor);
devices[i].dev = NULL;
devices[i].minor = -1;
- printk("tvmixer: %s unregistered (#1)\n",client->name);
+ printk("tvmixer: %s unregistered (#1)\n",
+ i2c_clientname(client));
return 0;
}
}
@@ -289,25 +281,13 @@
}
/* audio chip with mixer ??? */
- if (NULL == client->driver->command) {
- if (debug)
- printk("tvmixer: %s: driver->command is NULL\n",
- client->driver->name);
+ if (NULL == client->driver->command)
return -1;
- }
memset(&va,0,sizeof(va));
- if (0 != client->driver->command(client,VIDIOCGAUDIO,&va)) {
- if (debug)
- printk("tvmixer: %s: VIDIOCGAUDIO failed\n",
- client->name);
+ if (0 != client->driver->command(client,VIDIOCGAUDIO,&va))
return -1;
- }
- if (0 == (va.flags & VIDEO_AUDIO_VOLUME)) {
- if (debug)
- printk("tvmixer: %s: has no volume control\n",
- client->name);
+ if (0 == (va.flags & VIDEO_AUDIO_VOLUME))
return -1;
- }
/* everything is fine, register */
if ((minor = register_sound_mixer(&tvmixer_fops,devnr)) < 0) {
@@ -345,7 +325,7 @@
if (devices[i].minor != -1) {
unregister_sound_mixer(devices[i].minor);
printk("tvmixer: %s unregistered (#2)\n",
- devices[i].dev->name);
+ i2c_clientname(devices[i].dev));
}
}
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)