Commit 07ba111f authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman

staging/easycap: easycap_settings.c don't copy constant strings twice

eliminate copying twice a constant string just capture it using
const char * pointer

piggyback some other style fixes

Cc: Mike Thomas <rmthomas@sciolus.org>
Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 31410596
...@@ -313,145 +313,146 @@ const struct easycap_standard easycap_standard[] = { ...@@ -313,145 +313,146 @@ const struct easycap_standard easycap_standard[] = {
struct easycap_format easycap_format[1 + SETTINGS_MANY]; struct easycap_format easycap_format[1 + SETTINGS_MANY];
int int fillin_formats(void)
fillin_formats(void)
{ {
const char *name1, *name2, *name3, *name4;
struct v4l2_format *fmt;
int i, j, k, m, n; int i, j, k, m, n;
u32 width, height, pixelformat, bytesperline, sizeimage; u32 width, height, pixelformat, bytesperline, sizeimage;
u16 mask1, mask2, mask3, mask4;
enum v4l2_field field; enum v4l2_field field;
enum v4l2_colorspace colorspace; enum v4l2_colorspace colorspace;
u16 mask1, mask2, mask3, mask4;
char name1[32], name2[32], name3[32], name4[32];
for (i = 0, n = 0; i < STANDARD_MANY; i++) { for (i = 0, n = 0; i < STANDARD_MANY; i++) {
mask1 = 0x0000; mask1 = 0x0000;
switch (i) { switch (i) {
case PAL_BGHIN: { case PAL_BGHIN: {
mask1 = 0x1F & PAL_BGHIN; mask1 = 0x1F & PAL_BGHIN;
strcpy(&name1[0], "PAL_BGHIN"); name1 = "PAL_BGHIN";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case SECAM: { case SECAM: {
mask1 = 0x1F & SECAM; mask1 = 0x1F & SECAM;
strcpy(&name1[0], "SECAM"); name1 = "SECAM";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case PAL_Nc: { case PAL_Nc: {
mask1 = 0x1F & PAL_Nc; mask1 = 0x1F & PAL_Nc;
strcpy(&name1[0], "PAL_Nc"); name1 = "PAL_Nc";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case PAL_60: { case PAL_60: {
mask1 = 0x1F & PAL_60; mask1 = 0x1F & PAL_60;
strcpy(&name1[0], "PAL_60"); name1 = "PAL_60";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case PAL_M: { case PAL_M: {
mask1 = 0x1F & PAL_M; mask1 = 0x1F & PAL_M;
strcpy(&name1[0], "PAL_M"); name1 = "PAL_M";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case NTSC_M: { case NTSC_M: {
mask1 = 0x1F & NTSC_M; mask1 = 0x1F & NTSC_M;
strcpy(&name1[0], "NTSC_M"); name1 = "NTSC_M";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_443: { case NTSC_443: {
mask1 = 0x1F & NTSC_443; mask1 = 0x1F & NTSC_443;
strcpy(&name1[0], "NTSC_443"); name1 = "NTSC_443";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_M_JP: { case NTSC_M_JP: {
mask1 = 0x1F & NTSC_M_JP; mask1 = 0x1F & NTSC_M_JP;
strcpy(&name1[0], "NTSC_M_JP"); name1 = "NTSC_M_JP";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_N: { case NTSC_N: {
mask1 = 0x1F & NTSC_M; mask1 = 0x1F & NTSC_M;
strcpy(&name1[0], "NTSC_N"); name1 = "NTSC_N";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_N_443: { case NTSC_N_443: {
mask1 = 0x1F & NTSC_N_443; mask1 = 0x1F & NTSC_N_443;
strcpy(&name1[0], "NTSC_N_443"); name1 = "NTSC_N_443";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case PAL_BGHIN_SLOW: { case PAL_BGHIN_SLOW: {
mask1 = 0x001F & PAL_BGHIN_SLOW; mask1 = 0x001F & PAL_BGHIN_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "PAL_BGHIN_SLOW"); name1 = "PAL_BGHIN_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case SECAM_SLOW: { case SECAM_SLOW: {
mask1 = 0x001F & SECAM_SLOW; mask1 = 0x001F & SECAM_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "SECAM_SLOW"); name1 = "SECAM_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case PAL_Nc_SLOW: { case PAL_Nc_SLOW: {
mask1 = 0x001F & PAL_Nc_SLOW; mask1 = 0x001F & PAL_Nc_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "PAL_Nc_SLOW"); name1 = "PAL_Nc_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case PAL_60_SLOW: { case PAL_60_SLOW: {
mask1 = 0x001F & PAL_60_SLOW; mask1 = 0x001F & PAL_60_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "PAL_60_SLOW"); name1 = "PAL_60_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case PAL_M_SLOW: { case PAL_M_SLOW: {
mask1 = 0x001F & PAL_M_SLOW; mask1 = 0x001F & PAL_M_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "PAL_M_SLOW"); name1 = "PAL_M_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_BG; colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
break; break;
} }
case NTSC_M_SLOW: { case NTSC_M_SLOW: {
mask1 = 0x001F & NTSC_M_SLOW; mask1 = 0x001F & NTSC_M_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "NTSC_M_SLOW"); name1 = "NTSC_M_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_443_SLOW: { case NTSC_443_SLOW: {
mask1 = 0x001F & NTSC_443_SLOW; mask1 = 0x001F & NTSC_443_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "NTSC_443_SLOW"); name1 = "NTSC_443_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_M_JP_SLOW: { case NTSC_M_JP_SLOW: {
mask1 = 0x001F & NTSC_M_JP_SLOW; mask1 = 0x001F & NTSC_M_JP_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "NTSC_M_JP_SLOW"); name1 = "NTSC_M_JP_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_N_SLOW: { case NTSC_N_SLOW: {
mask1 = 0x001F & NTSC_N_SLOW; mask1 = 0x001F & NTSC_N_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "NTSC_N_SLOW"); name1 = "NTSC_N_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
case NTSC_N_443_SLOW: { case NTSC_N_443_SLOW: {
mask1 = 0x001F & NTSC_N_443_SLOW; mask1 = 0x001F & NTSC_N_443_SLOW;
mask1 |= 0x0200; mask1 |= 0x0200;
strcpy(&name1[0], "NTSC_N_443_SLOW"); name1 = "NTSC_N_443_SLOW";
colorspace = V4L2_COLORSPACE_470_SYSTEM_M; colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
break; break;
} }
...@@ -465,7 +466,7 @@ fillin_formats(void) ...@@ -465,7 +466,7 @@ fillin_formats(void)
case AT_720x576: { case AT_720x576: {
if (0x1 & mask1) if (0x1 & mask1)
continue; continue;
strcpy(&name2[0], "_AT_720x576"); name2 = "_AT_720x576";
width = 720; width = 720;
height = 576; height = 576;
break; break;
...@@ -473,13 +474,13 @@ fillin_formats(void) ...@@ -473,13 +474,13 @@ fillin_formats(void)
case AT_704x576: { case AT_704x576: {
if (0x1 & mask1) if (0x1 & mask1)
continue; continue;
strcpy(&name2[0], "_AT_704x576"); name2 = "_AT_704x576";
width = 704; width = 704;
height = 576; height = 576;
break; break;
} }
case AT_640x480: { case AT_640x480: {
strcpy(&name2[0], "_AT_640x480"); name2 = "_AT_640x480";
width = 640; width = 640;
height = 480; height = 480;
break; break;
...@@ -487,7 +488,7 @@ fillin_formats(void) ...@@ -487,7 +488,7 @@ fillin_formats(void)
case AT_720x480: { case AT_720x480: {
if (!(0x1 & mask1)) if (!(0x1 & mask1))
continue; continue;
strcpy(&name2[0], "_AT_720x480"); name2 = "_AT_720x480";
width = 720; width = 720;
height = 480; height = 480;
break; break;
...@@ -495,14 +496,14 @@ fillin_formats(void) ...@@ -495,14 +496,14 @@ fillin_formats(void)
case AT_360x288: { case AT_360x288: {
if (0x1 & mask1) if (0x1 & mask1)
continue; continue;
strcpy(&name2[0], "_AT_360x288"); name2 = "_AT_360x288";
width = 360; width = 360;
height = 288; height = 288;
mask2 = 0x0800; mask2 = 0x0800;
break; break;
} }
case AT_320x240: { case AT_320x240: {
strcpy(&name2[0], "_AT_320x240"); name2 = "_AT_320x240";
width = 320; width = 320;
height = 240; height = 240;
mask2 = 0x0800; mask2 = 0x0800;
...@@ -511,7 +512,7 @@ fillin_formats(void) ...@@ -511,7 +512,7 @@ fillin_formats(void)
case AT_360x240: { case AT_360x240: {
if (!(0x1 & mask1)) if (!(0x1 & mask1))
continue; continue;
strcpy(&name2[0], "_AT_360x240"); name2 = "_AT_360x240";
width = 360; width = 360;
height = 240; height = 240;
mask2 = 0x0800; mask2 = 0x0800;
...@@ -525,39 +526,39 @@ fillin_formats(void) ...@@ -525,39 +526,39 @@ fillin_formats(void)
mask3 = 0x0000; mask3 = 0x0000;
switch (k) { switch (k) {
case FMT_UYVY: { case FMT_UYVY: {
strcpy(&name3[0], "_" __stringify(FMT_UYVY)); name3 = __stringify(FMT_UYVY);
pixelformat = V4L2_PIX_FMT_UYVY; pixelformat = V4L2_PIX_FMT_UYVY;
mask3 |= (0x02 << 5); mask3 |= (0x02 << 5);
break; break;
} }
case FMT_YUY2: { case FMT_YUY2: {
strcpy(&name3[0], "_" __stringify(FMT_YUY2)); name3 = __stringify(FMT_YUY2);
pixelformat = V4L2_PIX_FMT_YUYV; pixelformat = V4L2_PIX_FMT_YUYV;
mask3 |= (0x02 << 5); mask3 |= (0x02 << 5);
mask3 |= 0x0100; mask3 |= 0x0100;
break; break;
} }
case FMT_RGB24: { case FMT_RGB24: {
strcpy(&name3[0], "_" __stringify(FMT_RGB24)); name3 = __stringify(FMT_RGB24);
pixelformat = V4L2_PIX_FMT_RGB24; pixelformat = V4L2_PIX_FMT_RGB24;
mask3 |= (0x03 << 5); mask3 |= (0x03 << 5);
break; break;
} }
case FMT_RGB32: { case FMT_RGB32: {
strcpy(&name3[0], "_" __stringify(FMT_RGB32)); name3 = __stringify(FMT_RGB32);
pixelformat = V4L2_PIX_FMT_RGB32; pixelformat = V4L2_PIX_FMT_RGB32;
mask3 |= (0x04 << 5); mask3 |= (0x04 << 5);
break; break;
} }
case FMT_BGR24: { case FMT_BGR24: {
strcpy(&name3[0], "_" __stringify(FMT_BGR24)); name3 = __stringify(FMT_BGR24);
pixelformat = V4L2_PIX_FMT_BGR24; pixelformat = V4L2_PIX_FMT_BGR24;
mask3 |= (0x03 << 5); mask3 |= (0x03 << 5);
mask3 |= 0x0100; mask3 |= 0x0100;
break; break;
} }
case FMT_BGR32: { case FMT_BGR32: {
strcpy(&name3[0], "_" __stringify(FMT_BGR32)); name3 = __stringify(FMT_BGR32);
pixelformat = V4L2_PIX_FMT_BGR32; pixelformat = V4L2_PIX_FMT_BGR32;
mask3 |= (0x04 << 5); mask3 |= (0x04 << 5);
mask3 |= 0x0100; mask3 |= 0x0100;
...@@ -573,12 +574,12 @@ fillin_formats(void) ...@@ -573,12 +574,12 @@ fillin_formats(void)
mask4 = 0x0000; mask4 = 0x0000;
switch (m) { switch (m) {
case FIELD_NONE: { case FIELD_NONE: {
strcpy(&name4[0], "-n"); name4 = "-n";
field = V4L2_FIELD_NONE; field = V4L2_FIELD_NONE;
break; break;
} }
case FIELD_INTERLACED: { case FIELD_INTERLACED: {
strcpy(&name4[0], "-i"); name4 = "-i";
mask4 |= 0x1000; mask4 |= 0x1000;
field = V4L2_FIELD_INTERLACED; field = V4L2_FIELD_INTERLACED;
break; break;
...@@ -588,30 +589,25 @@ fillin_formats(void) ...@@ -588,30 +589,25 @@ fillin_formats(void)
} }
if (SETTINGS_MANY <= n) if (SETTINGS_MANY <= n)
return -5; return -5;
strcpy(&easycap_format[n].name[0], &name1[0]);
strcat(&easycap_format[n].name[0], &name2[0]); strcpy(easycap_format[n].name, name1);
strcat(&easycap_format[n].name[0], &name3[0]); strcat(easycap_format[n].name, name2);
strcat(&easycap_format[n].name[0], &name4[0]); strcat(easycap_format[n].name, "_");
strcat(easycap_format[n].name, name3);
strcat(easycap_format[n].name, name4);
easycap_format[n].mask = easycap_format[n].mask =
mask1 | mask2 | mask3 | mask4; mask1 | mask2 | mask3 | mask4;
easycap_format[n].v4l2_format fmt = &easycap_format[n].v4l2_format;
.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
easycap_format[n].v4l2_format fmt->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
.fmt.pix.width = width; fmt->fmt.pix.width = width;
easycap_format[n].v4l2_format fmt->fmt.pix.height = height;
.fmt.pix.height = height; fmt->fmt.pix.pixelformat = pixelformat;
easycap_format[n].v4l2_format fmt->fmt.pix.field = field;
.fmt.pix.pixelformat = pixelformat; fmt->fmt.pix.bytesperline = bytesperline;
easycap_format[n].v4l2_format fmt->fmt.pix.sizeimage = sizeimage;
.fmt.pix.field = field; fmt->fmt.pix.colorspace = colorspace;
easycap_format[n].v4l2_format fmt->fmt.pix.priv = 0;
.fmt.pix.bytesperline = bytesperline;
easycap_format[n].v4l2_format
.fmt.pix.sizeimage = sizeimage;
easycap_format[n].v4l2_format
.fmt.pix.colorspace = colorspace;
easycap_format[n].v4l2_format
.fmt.pix.priv = 0;
n++; n++;
} }
} }
...@@ -623,8 +619,8 @@ fillin_formats(void) ...@@ -623,8 +619,8 @@ fillin_formats(void)
return n; return n;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
struct v4l2_queryctrl easycap_control[] = struct v4l2_queryctrl easycap_control[] = {
{{ {
.id = V4L2_CID_BRIGHTNESS, .id = V4L2_CID_BRIGHTNESS,
.type = V4L2_CTRL_TYPE_INTEGER, .type = V4L2_CTRL_TYPE_INTEGER,
.name = "Brightness", .name = "Brightness",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment