提交 c682b3a7 编写于 作者: T Trent Piepho 提交者: Mauro Carvalho Chehab

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: NTrent Piepho <xyzzy@speakeasy.org>
Acked-by: NThierry MERLE <thierry.merle@free.fr>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 f7ca6256
......@@ -2040,8 +2040,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision)
return 0;
/* Set input format expected from decoder*/
if (usbvision_device_data[usbvision->DevModel].Vin_Reg1 >= 0) {
value[0] = usbvision_device_data[usbvision->DevModel].Vin_Reg1 & 0xff;
if (usbvision_device_data[usbvision->DevModel].Vin_Reg1_override) {
value[0] = usbvision_device_data[usbvision->DevModel].Vin_Reg1;
} else if(usbvision_device_data[usbvision->DevModel].Codec == CODEC_SAA7113) {
/* SAA7113 uses 8 bit output */
value[0] = USBVISION_8_422_SYNC;
......@@ -2112,8 +2112,8 @@ int usbvision_set_input(struct usb_usbvision *usbvision)
dvi_yuv_value = 0x00; /* U comes after V, Ya comes after U/V, Yb comes after Yb */
if(usbvision_device_data[usbvision->DevModel].Dvi_yuv >= 0){
dvi_yuv_value = usbvision_device_data[usbvision->DevModel].Dvi_yuv & 0xff;
if(usbvision_device_data[usbvision->DevModel].Dvi_yuv_override){
dvi_yuv_value = usbvision_device_data[usbvision->DevModel].Dvi_yuv;
}
else if(usbvision_device_data[usbvision->DevModel].Codec == CODEC_SAA7113) {
/* This changes as the fine sync control changes. Further investigation necessary */
......
......@@ -1745,8 +1745,8 @@ static void usbvision_configure_video(struct usb_usbvision *usbvision)
model = usbvision->DevModel;
usbvision->palette = usbvision_v4l2_format[2]; // V4L2_PIX_FMT_RGB24;
if (usbvision_device_data[usbvision->DevModel].Vin_Reg2 >= 0) {
usbvision->Vin_Reg2_Preset = usbvision_device_data[usbvision->DevModel].Vin_Reg2 & 0xff;
if (usbvision_device_data[usbvision->DevModel].Vin_Reg2_override) {
usbvision->Vin_Reg2_Preset = usbvision_device_data[usbvision->DevModel].Vin_Reg2;
} else {
usbvision->Vin_Reg2_Preset = 0;
}
......@@ -1957,6 +1957,7 @@ static void customdevice_process(void)
if(CustomDevice)
{
char *parse=CustomDevice;
int tmp;
PDEBUG(DBG_PROBE, "CustomDevice=%s", CustomDevice);
......@@ -1996,10 +1997,11 @@ static void customdevice_process(void)
sscanf(parse,"%d",&usbvision_device_data[0].Interface);
goto2next(parse);
PDEBUG(DBG_PROBE, "Interface=%d", usbvision_device_data[0].Interface);
sscanf(parse,"%d",&usbvision_device_data[0].Codec);
sscanf(parse,"%hd",&usbvision_device_data[0].Codec);
goto2next(parse);
PDEBUG(DBG_PROBE, "Codec=%d", usbvision_device_data[0].Codec);
sscanf(parse,"%d",&usbvision_device_data[0].VideoChannels);
sscanf(parse,"%d",&tmp);
usbvision_device_data[0].VideoChannels = tmp;
goto2next(parse);
PDEBUG(DBG_PROBE, "VideoChannels=%d", usbvision_device_data[0].VideoChannels);
......@@ -2027,7 +2029,8 @@ static void customdevice_process(void)
}
goto2next(parse);
sscanf(parse,"%d",&usbvision_device_data[0].AudioChannels);
sscanf(parse,"%d",&tmp);
usbvision_device_data[0].AudioChannels = tmp;
goto2next(parse);
PDEBUG(DBG_PROBE, "AudioChannels=%d", usbvision_device_data[0].AudioChannels);
sscanf(parse,"%d",&radio);
......@@ -2038,22 +2041,34 @@ static void customdevice_process(void)
usbvision_device_data[0].Tuner=(tuner?1:0);
goto2next(parse);
PDEBUG(DBG_PROBE, "Tuner=%d", usbvision_device_data[0].Tuner);
sscanf(parse,"%d",&usbvision_device_data[0].TunerType);
sscanf(parse,"%hhu",&usbvision_device_data[0].TunerType);
goto2next(parse);
PDEBUG(DBG_PROBE, "TunerType=%d", usbvision_device_data[0].TunerType);
sscanf(parse,"%d",&usbvision_device_data[0].Vin_Reg1);
sscanf(parse,"%d",&tmp);
if(tmp>0) {
usbvision_device_data[0].Vin_Reg1_override = 1;
usbvision_device_data[0].Vin_Reg1 = tmp&0xff;
}
goto2next(parse);
PDEBUG(DBG_PROBE, "Vin_Reg1=%d", usbvision_device_data[0].Vin_Reg1);
sscanf(parse,"%d",&usbvision_device_data[0].Vin_Reg2);
sscanf(parse,"%d",&tmp);
if(tmp>0) {
usbvision_device_data[0].Vin_Reg2_override = 1;
usbvision_device_data[0].Vin_Reg2 = tmp&0xff;
}
goto2next(parse);
PDEBUG(DBG_PROBE, "Vin_Reg2=%d", usbvision_device_data[0].Vin_Reg2);
sscanf(parse,"%d",&usbvision_device_data[0].X_Offset);
sscanf(parse,"%hd",&usbvision_device_data[0].X_Offset);
goto2next(parse);
PDEBUG(DBG_PROBE, "X_Offset=%d", usbvision_device_data[0].X_Offset);
sscanf(parse,"%d",&usbvision_device_data[0].Y_Offset);
sscanf(parse,"%hd",&usbvision_device_data[0].Y_Offset);
goto2next(parse);
PDEBUG(DBG_PROBE, "Y_Offset=%d", usbvision_device_data[0].Y_Offset);
sscanf(parse,"%d",&usbvision_device_data[0].Dvi_yuv);
sscanf(parse,"%d",&tmp);
if(tmp>0) {
usbvision_device_data[0].Dvi_yuv_override = 1;
usbvision_device_data[0].Dvi_yuv = tmp&0xff;
}
PDEBUG(DBG_PROBE, "Dvi_yuv=%d", usbvision_device_data[0].Dvi_yuv);
//add to usbvision_table also
......
......@@ -342,21 +342,24 @@ struct usbvision_frame {
#define BRIDGE_NT1005 1005
struct usbvision_device_data_st {
int Interface; /* to handle special interface number like BELKIN and Hauppauge WinTV-USB II */
int Codec;
int VideoChannels;
__u64 VideoNorm;
int AudioChannels;
int Radio:1;
int vbi:1;
int Tuner:1;
int TunerType;
int Vin_Reg1;
int Vin_Reg2;
int X_Offset;
int Y_Offset;
int Dvi_yuv;
char *ModelString;
const char *ModelString;
int Interface; /* to handle special interface number like BELKIN and Hauppauge WinTV-USB II */
__u16 Codec;
unsigned VideoChannels:3;
unsigned AudioChannels:2;
unsigned Radio:1;
unsigned vbi:1;
unsigned Tuner:1;
unsigned Vin_Reg1_override:1; /* Override default value with */
unsigned Vin_Reg2_override:1; /* Vin_Reg1, Vin_Reg2, etc. */
unsigned Dvi_yuv_override:1;
__u8 Vin_Reg1;
__u8 Vin_Reg2;
__u8 Dvi_yuv;
__u8 TunerType;
__s16 X_Offset;
__s16 Y_Offset;
};
/* Declared on usbvision-cards.c */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册