aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvision/usbvision-video.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-04-14 14:16:26 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-04-27 14:45:34 -0400
commitc682b3a7fb8ec69ac73511bbb6a378e40aa35f35 (patch)
tree443ac5b210222822c3f4883964defd2404601d7a /drivers/media/video/usbvision/usbvision-video.c
parentf7ca6256bc1db4fb44adda99e082f8c80ada8957 (diff)
V4L/DVB (5517): Usbvision: store the device database more efficiently
One bit wide bitfields need to declared unsigned to have the range 0 to 1, or they have the range -1 to 0. A few techniques to reduce the driver's size by about 1700 bytes on ia32, probably more on x86-64. Put the biggest fields first, less padding is necessary that way. Put fields with a limited range into a smaller type. For example VideoChannels will fit in 3 bits, and TunerType can use 8 bits. Vin_Reg1, Vin_Reg2, and Dvi_yuv define values for 8-bit registers, but they can't just go into an 8-bit field with no changes, since -1 was used as a flag to indicate a value was not present. So what we do is create a one-bit flag for each one to indicate if a value is or is not present. This only takes 9 bits and has the added advantage that when the register isn't overridden (Vin_Reg[12] never are) it doesn't need to appear in the structure definition since the default value for the flag will be zero. Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Acked-by: Thierry MERLE <thierry.merle@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-video.c')
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 49281ffa84cb..aa6509391bf9 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -1745,8 +1745,8 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision)
1745 model = usbvision->DevModel; 1745 model = usbvision->DevModel;
1746 usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24; 1746 usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24;
1747 1747
1748 if (usbvision_device_data[usbvision->DevModel].Vin_Reg2 >= 0) { 1748 if (usbvision_device_data[usbvision->DevModel].Vin_Reg2_override) {
1749 usbvision->Vin_Reg2_Preset = usbvision_device_data[usbvision->DevModel].Vin_Reg2 & 0xff; 1749 usbvision->Vin_Reg2_Preset = usbvision_device_data[usbvision->DevModel].Vin_Reg2;
1750 } else { 1750 } else {
1751 usbvision->Vin_Reg2_Preset = 0; 1751 usbvision->Vin_Reg2_Preset = 0;
1752 } 1752 }
@@ -1957,6 +1957,7 @@ static void customdevice_process(void)
1957 if(CustomDevice) 1957 if(CustomDevice)
1958 { 1958 {
1959 char *parse=CustomDevice; 1959 char *parse=CustomDevice;
1960 int tmp;
1960 1961
1961 PDEBUG(DBG_PROBE, "CustomDevice=%s", CustomDevice); 1962 PDEBUG(DBG_PROBE, "CustomDevice=%s", CustomDevice);
1962 1963
@@ -1996,10 +1997,11 @@ static void customdevice_process(void)
1996 sscanf(parse,"%d",&usbvision_device_data[0].Interface); 1997 sscanf(parse,"%d",&usbvision_device_data[0].Interface);
1997 goto2next(parse); 1998 goto2next(parse);
1998 PDEBUG(DBG_PROBE, "Interface=%d", usbvision_device_data[0].Interface); 1999 PDEBUG(DBG_PROBE, "Interface=%d", usbvision_device_data[0].Interface);
1999 sscanf(parse,"%d",&usbvision_device_data[0].Codec); 2000 sscanf(parse,"%hd",&usbvision_device_data[0].Codec);
2000 goto2next(parse); 2001 goto2next(parse);
2001 PDEBUG(DBG_PROBE, "Codec=%d", usbvision_device_data[0].Codec); 2002 PDEBUG(DBG_PROBE, "Codec=%d", usbvision_device_data[0].Codec);
2002 sscanf(parse,"%d",&usbvision_device_data[0].VideoChannels); 2003 sscanf(parse,"%d",&tmp);
2004 usbvision_device_data[0].VideoChannels = tmp;
2003 goto2next(parse); 2005 goto2next(parse);
2004 PDEBUG(DBG_PROBE, "VideoChannels=%d", usbvision_device_data[0].VideoChannels); 2006 PDEBUG(DBG_PROBE, "VideoChannels=%d", usbvision_device_data[0].VideoChannels);
2005 2007
@@ -2027,7 +2029,8 @@ static void customdevice_process(void)
2027 } 2029 }
2028 goto2next(parse); 2030 goto2next(parse);
2029 2031
2030 sscanf(parse,"%d",&usbvision_device_data[0].AudioChannels); 2032 sscanf(parse,"%d",&tmp);
2033 usbvision_device_data[0].AudioChannels = tmp;
2031 goto2next(parse); 2034 goto2next(parse);
2032 PDEBUG(DBG_PROBE, "AudioChannels=%d", usbvision_device_data[0].AudioChannels); 2035 PDEBUG(DBG_PROBE, "AudioChannels=%d", usbvision_device_data[0].AudioChannels);
2033 sscanf(parse,"%d",&radio); 2036 sscanf(parse,"%d",&radio);
@@ -2038,22 +2041,34 @@ static void customdevice_process(void)
2038 usbvision_device_data[0].Tuner=(tuner?1:0); 2041 usbvision_device_data[0].Tuner=(tuner?1:0);
2039 goto2next(parse); 2042 goto2next(parse);
2040 PDEBUG(DBG_PROBE, "Tuner=%d", usbvision_device_data[0].Tuner); 2043 PDEBUG(DBG_PROBE, "Tuner=%d", usbvision_device_data[0].Tuner);
2041 sscanf(parse,"%d",&usbvision_device_data[0].TunerType); 2044 sscanf(parse,"%hhu",&usbvision_device_data[0].TunerType);
2042 goto2next(parse); 2045 goto2next(parse);
2043 PDEBUG(DBG_PROBE, "TunerType=%d", usbvision_device_data[0].TunerType); 2046 PDEBUG(DBG_PROBE, "TunerType=%d", usbvision_device_data[0].TunerType);
2044 sscanf(parse,"%d",&usbvision_device_data[0].Vin_Reg1); 2047 sscanf(parse,"%d",&tmp);
2048 if(tmp>0) {
2049 usbvision_device_data[0].Vin_Reg1_override = 1;
2050 usbvision_device_data[0].Vin_Reg1 = tmp&0xff;
2051 }
2045 goto2next(parse); 2052 goto2next(parse);
2046 PDEBUG(DBG_PROBE, "Vin_Reg1=%d", usbvision_device_data[0].Vin_Reg1); 2053 PDEBUG(DBG_PROBE, "Vin_Reg1=%d", usbvision_device_data[0].Vin_Reg1);
2047 sscanf(parse,"%d",&usbvision_device_data[0].Vin_Reg2); 2054 sscanf(parse,"%d",&tmp);
2055 if(tmp>0) {
2056 usbvision_device_data[0].Vin_Reg2_override = 1;
2057 usbvision_device_data[0].Vin_Reg2 = tmp&0xff;
2058 }
2048 goto2next(parse); 2059 goto2next(parse);
2049 PDEBUG(DBG_PROBE, "Vin_Reg2=%d", usbvision_device_data[0].Vin_Reg2); 2060 PDEBUG(DBG_PROBE, "Vin_Reg2=%d", usbvision_device_data[0].Vin_Reg2);
2050 sscanf(parse,"%d",&usbvision_device_data[0].X_Offset); 2061 sscanf(parse,"%hd",&usbvision_device_data[0].X_Offset);
2051 goto2next(parse); 2062 goto2next(parse);
2052 PDEBUG(DBG_PROBE, "X_Offset=%d", usbvision_device_data[0].X_Offset); 2063 PDEBUG(DBG_PROBE, "X_Offset=%d", usbvision_device_data[0].X_Offset);
2053 sscanf(parse,"%d",&usbvision_device_data[0].Y_Offset); 2064 sscanf(parse,"%hd",&usbvision_device_data[0].Y_Offset);
2054 goto2next(parse); 2065 goto2next(parse);
2055 PDEBUG(DBG_PROBE, "Y_Offset=%d", usbvision_device_data[0].Y_Offset); 2066 PDEBUG(DBG_PROBE, "Y_Offset=%d", usbvision_device_data[0].Y_Offset);
2056 sscanf(parse,"%d",&usbvision_device_data[0].Dvi_yuv); 2067 sscanf(parse,"%d",&tmp);
2068 if(tmp>0) {
2069 usbvision_device_data[0].Dvi_yuv_override = 1;
2070 usbvision_device_data[0].Dvi_yuv = tmp&0xff;
2071 }
2057 PDEBUG(DBG_PROBE, "Dvi_yuv=%d", usbvision_device_data[0].Dvi_yuv); 2072 PDEBUG(DBG_PROBE, "Dvi_yuv=%d", usbvision_device_data[0].Dvi_yuv);
2058 2073
2059 //add to usbvision_table also 2074 //add to usbvision_table also