• Hans de Goede's avatar
    [media] [REGRESSION] bt8xx: Fix too large height in cropcap · 35ccecef
    Hans de Goede authored
    Since commit a1fd2877:
    "[media] bttv-driver: fix two warnings"
    cropcap.defrect.height and cropcap.bounds.height for the PAL entry are 32
    resp 30 pixels too large, if a userspace app (ie xawtv) actually tries to use
    the full advertised height, the resulting image is broken in ways only a
    screenshot can describe.
    The cause of this is the fix for this warning:
    drivers/media/pci/bt8xx/bttv-driver.c:308:3: warning: initialized field overwritten [-Woverride-init]
    In this chunk of the commit:
    @@ -301,11 +301,10 @@ const struct bttv_tvnorm bttv_tvnorms[] = {
                            /* totalwidth */ 1135,
                            /* sqwidth */ 944,
                            /* vdelay */ 0x20,
    -                       /* sheight */ 576,
    -                       /* videostart0 */ 23)
                    /* bt878 (and bt848?) can capture another
                       line below active video. */
    -               .cropcap.bounds.height = (576 + 2) + 0x20 - 2,
    +                       /* sheight */ (576 + 2) + 0x20 - 2,
    +                       /* videostart0 */ 23)
            },{
                    .v4l2_id        = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR,
                    .name           = "NTSC",
    Which replaces the overriding of cropcap.bounds.height initialization outside
    of the CROPCAP macro (which also initializes it), with passing a
    different sheight value to the CROPCAP macro.
    There are 2 problems with this warning fix:
    1) The sheight value is used twice in the CROPCAP macro, and the old code
       only changed one resulting value.
    2) The old code increased the .cropcap.bounds.height value (and did not
       touch the .cropcap.defrect.height value at all) by 2, where as the fixed
       code increases it by 32, as the fixed code passes (576 + 2) + 0x20 - 2
       to the CROPCAP macro, but the + 0x20 - 2 is already done by the macro so
       now is done twice for .cropcap.bounds.height, and also is applied to
       .cropcap.defrect.height where it should not be applied at all.
    This patch fixes this by adding an extraheight parameter to the CROPCAP entry
    and using it for the PAL entry.
    
    Cc: stable@kernel.org	# For Kernel 3.8
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
    35ccecef
bttv-driver.c 118 KB