cx18: use macros instead of static const vars
authorMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 24 Jun 2016 11:40:51 +0000 (08:40 -0300)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Fri, 24 Jun 2016 11:50:24 +0000 (08:50 -0300)
Gcc 6.1 now complains about unused vars:

drivers/media/pci/cx18/cx18-driver.h:497:18: warning: 'vbi_hblank_samples_50Hz' defined but not used [-Wunused-const-variable=]
 static const u32 vbi_hblank_samples_50Hz = 284; /* 4 byte EAV + 280 anc/fill */
                  ^~~~~~~~~~~~~~~~~~~~~~~
drivers/media/pci/cx18/cx18-driver.h:496:18: warning: 'vbi_hblank_samples_60Hz' defined but not used [-Wunused-const-variable=]
 static const u32 vbi_hblank_samples_60Hz = 272; /* 4 byte EAV + 268 anc/fill */
                  ^~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/media/pci/cx18/cx18-cards.c:25:0:
drivers/media/pci/cx18/cx18-driver.h:497:18: warning: 'vbi_hblank_samples_50Hz' defined but not used [-Wunused-const-variable=]
 static const u32 vbi_hblank_samples_50Hz = 284; /* 4 byte EAV + 280 anc/fill */
                  ^~~~~~~~~~~~~~~~~~~~~~~
drivers/media/pci/cx18/cx18-driver.h:496:18: warning: 'vbi_hblank_samples_60Hz' defined but not used [-Wunused-const-variable=]
 static const u32 vbi_hblank_samples_60Hz = 272; /* 4 byte EAV + 268 anc/fill */
                  ^~~~~~~~~~~~~~~~~~~~~~~
drivers/media/pci/cx18/cx18-driver.h:495:18: warning: 'vbi_active_samples' defined but not used [-Wunused-const-variable=]
 static const u32 vbi_active_samples = 1444; /* 4 byte SAV + 720 Y + 720 U/V */
                  ^~~~~~~~~~~~~~~~~~

In this specific case, this is somewhat intentional, as those
values are actually used in parts of the driver. The code assumes
that gcc optimizer it and not actually create any var, but convert
it to immediate access at the routines.

Yet, as we want to shut up gcc warnings, let's use #define, with
is the standard way to store values that will use assembler's
immediate access code.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
drivers/media/pci/cx18/cx18-driver.c
drivers/media/pci/cx18/cx18-driver.h
drivers/media/pci/cx18/cx18-ioctl.c
drivers/media/pci/cx18/cx18-streams.c
drivers/media/pci/cx18/cx18-vbi.c

index 260e462d91b4a15d08958334b931ca851e263c61..2f23b26b16c07246014c600f72090f007ddda691 100644 (file)
@@ -560,7 +560,7 @@ static void cx18_process_options(struct cx18 *cx)
        cx->stream_buf_size[CX18_ENC_STREAM_TYPE_MPG] = enc_mpg_bufsize;
        cx->stream_buf_size[CX18_ENC_STREAM_TYPE_IDX] = enc_idx_bufsize;
        cx->stream_buf_size[CX18_ENC_STREAM_TYPE_YUV] = enc_yuv_bufsize;
-       cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = vbi_active_samples * 36;
+       cx->stream_buf_size[CX18_ENC_STREAM_TYPE_VBI] = VBI_ACTIVE_SAMPLES * 36;
        cx->stream_buf_size[CX18_ENC_STREAM_TYPE_PCM] = enc_pcm_bufsize;
        cx->stream_buf_size[CX18_ENC_STREAM_TYPE_RAD] = 0; /* control no data */
 
index 47ce80fa73b98612f6d1af80857ed0fcafa85cce..ef308a10e870c45a73b968a6da3d9b0ea3b4d56f 100644 (file)
@@ -492,9 +492,9 @@ struct cx18_card;
  *  (1/15.625 kHz) * 2 * 13.5 MHz = 1728 samples/line =
  *  4 bytes SAV + 280 bytes anc data + 4 bytes SAV + 1440 active samples
  */
-static const u32 vbi_active_samples = 1444; /* 4 byte SAV + 720 Y + 720 U/V */
-static const u32 vbi_hblank_samples_60Hz = 272; /* 4 byte EAV + 268 anc/fill */
-static const u32 vbi_hblank_samples_50Hz = 284; /* 4 byte EAV + 280 anc/fill */
+#define VBI_ACTIVE_SAMPLES     1444 /* 4 byte SAV + 720 Y + 720 U/V */
+#define VBI_HBLANK_SAMPLES_60HZ        272 /* 4 byte EAV + 268 anc/fill */
+#define VBI_HBLANK_SAMPLES_50HZ        284 /* 4 byte EAV + 280 anc/fill */
 
 #define CX18_VBI_FRAMES 32
 
index eeb741c7db1b2fe2e724a6c60f7202a94feedfc2..fecca2a638914e612c36d1a04c9ab62fa5a784dd 100644 (file)
@@ -177,7 +177,7 @@ static int cx18_g_fmt_vbi_cap(struct file *file, void *fh,
 
        vbifmt->sampling_rate = 27000000;
        vbifmt->offset = 248; /* FIXME - slightly wrong for both 50 & 60 Hz */
-       vbifmt->samples_per_line = vbi_active_samples - 4;
+       vbifmt->samples_per_line = VBI_ACTIVE_SAMPLES - 4;
        vbifmt->sample_format = V4L2_PIX_FMT_GREY;
        vbifmt->start[0] = cx->vbi.start[0];
        vbifmt->start[1] = cx->vbi.start[1];
index c9860845264fa120a711f8f5954c483d2e716ad4..f3802ec1b3837526b17ec2cd7ba8556619de412b 100644 (file)
@@ -605,9 +605,9 @@ static void cx18_vbi_setup(struct cx18_stream *s)
        /* Lines per field */
        data[1] = (lines / 2) | ((lines / 2) << 16);
        /* bytes per line */
-       data[2] = (raw ? vbi_active_samples
-                      : (cx->is_60hz ? vbi_hblank_samples_60Hz
-                                     : vbi_hblank_samples_50Hz));
+       data[2] = (raw ? VBI_ACTIVE_SAMPLES
+                      : (cx->is_60hz ? VBI_HBLANK_SAMPLES_60HZ
+                                     : VBI_HBLANK_SAMPLES_50HZ));
        /* Every X number of frames a VBI interrupt arrives
           (frames as in 25 or 30 fps) */
        data[3] = 1;
@@ -761,7 +761,7 @@ static void cx18_stream_configure_mdls(struct cx18_stream *s)
                s->bufs_per_mdl = 1;
                if  (cx18_raw_vbi(s->cx)) {
                        s->mdl_size = (s->cx->is_60hz ? 12 : 18)
-                                                      * 2 * vbi_active_samples;
+                                                      * 2 * VBI_ACTIVE_SAMPLES;
                } else {
                        /*
                         * See comment in cx18_vbi_setup() below about the
@@ -769,8 +769,8 @@ static void cx18_stream_configure_mdls(struct cx18_stream *s)
                         * the lines on which EAV RP codes toggle.
                        */
                        s->mdl_size = s->cx->is_60hz
-                                  ? (21 - 4 + 1) * 2 * vbi_hblank_samples_60Hz
-                                  : (23 - 2 + 1) * 2 * vbi_hblank_samples_50Hz;
+                                  ? (21 - 4 + 1) * 2 * VBI_HBLANK_SAMPLES_60HZ
+                                  : (23 - 2 + 1) * 2 * VBI_HBLANK_SAMPLES_50HZ;
                }
                break;
        default:
index add99642f1e279705177338283c2fee7e9604987..43360cbcf24b443b2d6ec4d9a73bc2cdb4bc3a69 100644 (file)
@@ -108,7 +108,7 @@ static void copy_vbi_data(struct cx18 *cx, int lines, u32 pts_stamp)
 /* FIXME - this function ignores the input size. */
 static u32 compress_raw_buf(struct cx18 *cx, u8 *buf, u32 size, u32 hdr_size)
 {
-       u32 line_size = vbi_active_samples;
+       u32 line_size = VBI_ACTIVE_SAMPLES;
        u32 lines = cx->vbi.count * 2;
        u8 *q = buf;
        u8 *p;
@@ -145,8 +145,8 @@ static u32 compress_sliced_buf(struct cx18 *cx, u8 *buf, u32 size,
        struct v4l2_decode_vbi_line vbi;
        int i;
        u32 line = 0;
-       u32 line_size = cx->is_60hz ? vbi_hblank_samples_60Hz
-                                   : vbi_hblank_samples_50Hz;
+       u32 line_size = cx->is_60hz ? VBI_HBLANK_SAMPLES_60HZ
+                                   : VBI_HBLANK_SAMPLES_50HZ;
 
        /* find the first valid line */
        for (i = hdr_size, buf += hdr_size; i < size; i++, buf++) {