adv7842: fix compilation with GCC < 4.4.6
Subsystems (2)
RFC PATCH 1/1 adv7842: fix compilation with GCC < 4.4.6
With GCC 4.4.3 (Ubuntu 10.04) the compilation of the new adv7842 driver fails with this error:
CC [M] adv7842.o
adv7842.c:549: error: unknown field 'bt' specified in initializer adv7842.c:550: error: field name not in record or union initializer adv7842.c:550: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:551: error: field name not in record or union initializer adv7842.c:551: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:552: error: field name not in record or union initializer adv7842.c:552: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:553: error: field name not in record or union initializer adv7842.c:553: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:553: warning: excess elements in array initializer
...
This is caused by the old GCC version, as explained in file v4l2-dv-timings.h. The proposed fix uses the V4L2_INIT_BT_TIMINGS macro defined there.
Please note that I have also to init the reserved space as otherwise GCC fails with this error:
CC [M] adv7842.o
adv7842.c:549: error: field name not in record or union initializer adv7842.c:549: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:549: warning: braces around scalar initializer
adv7842.c:549: warning: (near initialization for 'adv7842_timings_cap_analog.reserved[0]')
...
Maybe the reserved space in struct v4l2_dv_timings_cap could be moved after the 'bt' field to avoid this?
The same issue applies to other drivers too: ths8200, adv7511 and ad9389b. If the fix is approved, I can post a patch serie fixing all of them.
--- drivers/media/i2c/adv7842.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)
drivers/media/i2c/adv7842.c +10 -18
@@ -546,30 +546,22 @@ static inline bool is_digital_input(struct v4l2_subdev *sd)static const struct v4l2_dv_timings_cap adv7842_timings_cap_analog = { .type =V4L2_DV_BT_656_1120 , - .bt = { - .max_width =1920 , - .max_height =1200 , - .min_pixelclock =25000000 , - .max_pixelclock =170000000 , - .standards =V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT | + .reserved = {0 }, +V4L2_INIT_BT_TIMINGS (0 ,1920 ,0 ,1200 ,25000000 ,170000000 , +V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT |V4L2_DV_BT_STD_GTF |V4L2_DV_BT_STD_CVT , - .capabilities =V4L2_DV_BT_CAP_PROGRESSIVE | -V4L2_DV_BT_CAP_REDUCED_BLANKING |V4L2_DV_BT_CAP_CUSTOM , - }, +V4L2_DV_BT_CAP_PROGRESSIVE |V4L2_DV_BT_CAP_REDUCED_BLANKING | +V4L2_DV_BT_CAP_CUSTOM ) };static const struct v4l2_dv_timings_cap adv7842_timings_cap_digital = { .type =V4L2_DV_BT_656_1120 , - .bt = { - .max_width =1920 , - .max_height =1200 , - .min_pixelclock =25000000 , - .max_pixelclock =225000000 , - .standards =V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT | + .reserved = {0 }, +V4L2_INIT_BT_TIMINGS (0 ,1920 ,0 ,1200 ,25000000 ,225000000 , +V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT |V4L2_DV_BT_STD_GTF |V4L2_DV_BT_STD_CVT , - .capabilities =V4L2_DV_BT_CAP_PROGRESSIVE | -V4L2_DV_BT_CAP_REDUCED_BLANKING |V4L2_DV_BT_CAP_CUSTOM , - }, +V4L2_DV_BT_CAP_PROGRESSIVE |V4L2_DV_BT_CAP_REDUCED_BLANKING | +V4L2_DV_BT_CAP_CUSTOM ) }; static inline const struct v4l2_dv_timings_cap *
Signature · 1 line
1.8.4
Hi Gianluca,
Quoted 27 lines · On Fri 30 August 2013 11:50:27 Gianluca Gennari wrote:
With GCC 4.4.3 (Ubuntu 10.04) the compilation of the new adv7842 driver fails with this error:
CC [M] adv7842.o
adv7842.c:549: error: unknown field 'bt' specified in initializer adv7842.c:550: error: field name not in record or union initializer adv7842.c:550: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:551: error: field name not in record or union initializer adv7842.c:551: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:552: error: field name not in record or union initializer adv7842.c:552: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:553: error: field name not in record or union initializer adv7842.c:553: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:553: warning: excess elements in array initializer
...This is caused by the old GCC version, as explained in file
v4l2-dv-timings.h. The proposed fix uses theV4L2_INIT_BT_TIMINGSmacro defined there.
Please note that I have also to init the reserved space as otherwise GCC fails with this error:CC [M] adv7842.o
adv7842.c:549: error: field name not in record or union initializer adv7842.c:549: error: (near initialization for 'adv7842_timings_cap_analog.reserved') adv7842.c:549: warning: braces around scalar initializer
adv7842.c:549: warning: (near initialization for 'adv7842_timings_cap_analog.reserved[0]')
...
Quoted 2 lines
Maybe the reserved space in struct
v4l2_dv_timings_capcould be moved after the 'bt' field to avoid this?
No, it's part of the public API, so it can't be changed. It's OK to init the reserved space, although you should prefix it with a small comment saying that this is necessary when compiling with a gcc < 4.6.
Quoted 3 lines
The same issue applies to other drivers too: ths8200, adv7511 and ad9389b. If the fix is approved, I can post a patch serie fixing all of them.
Other than the point I made above it all looks fine.
Regards,
Hans
Quoted 52 lines
Signed-off-by Gianluca Gennari <[email protected]>--- drivers/media/i2c/adv7842.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-)drivers/media/i2c/adv7842.c +10
-18@@ -546,30 +546,22 @@ static inline bool is_digital_input(struct v4l2_subdev *sd)static const struct v4l2_dv_timings_cap adv7842_timings_cap_analog = { .type =V4L2_DV_BT_656_1120 , - .bt = { - .max_width =1920 , - .max_height =1200 , - .min_pixelclock =25000000 , - .max_pixelclock =170000000 , - .standards =V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT | + .reserved = {0 }, +V4L2_INIT_BT_TIMINGS (0 ,1920 ,0 ,1200 ,25000000 ,170000000 , +V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT |V4L2_DV_BT_STD_GTF |V4L2_DV_BT_STD_CVT , - .capabilities =V4L2_DV_BT_CAP_PROGRESSIVE | -V4L2_DV_BT_CAP_REDUCED_BLANKING |V4L2_DV_BT_CAP_CUSTOM , - }, +V4L2_DV_BT_CAP_PROGRESSIVE |V4L2_DV_BT_CAP_REDUCED_BLANKING | +V4L2_DV_BT_CAP_CUSTOM ) };static const struct v4l2_dv_timings_cap adv7842_timings_cap_digital = { .type =V4L2_DV_BT_656_1120 , - .bt = { - .max_width =1920 , - .max_height =1200 , - .min_pixelclock =25000000 , - .max_pixelclock =225000000 , - .standards =V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT | + .reserved = {0 }, +V4L2_INIT_BT_TIMINGS (0 ,1920 ,0 ,1200 ,25000000 ,225000000 , +V4L2_DV_BT_STD_CEA861 |V4L2_DV_BT_STD_DMT |V4L2_DV_BT_STD_GTF |V4L2_DV_BT_STD_CVT , - .capabilities =V4L2_DV_BT_CAP_PROGRESSIVE | -V4L2_DV_BT_CAP_REDUCED_BLANKING |V4L2_DV_BT_CAP_CUSTOM , - }, +V4L2_DV_BT_CAP_PROGRESSIVE |V4L2_DV_BT_CAP_REDUCED_BLANKING | +V4L2_DV_BT_CAP_CUSTOM ) }; static inline const struct v4l2_dv_timings_cap *