[media] [REGRESSION] bt8xx: Fix too large height in cropcap

Since commit a1fd287780c8e91fed4957b30c757b0c93021162:
"[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: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by Hans de Goede and committed by Mauro Carvalho Chehab 35ccecef 532ee00c

Changed files
+15 -5
drivers
media
pci
+15 -5
drivers/media/pci/bt8xx/bttv-driver.c
··· 250 250 vdelay start of active video in 2 * field lines relative to 251 251 trailing edge of /VRESET pulse (VDELAY register). 252 252 sheight height of active video in 2 * field lines. 253 + extraheight Added to sheight for cropcap.bounds.height only 253 254 videostart0 ITU-R frame line number of the line corresponding 254 255 to vdelay in the first field. */ 255 256 #define CROPCAP(minhdelayx1, hdelayx1, swidth, totalwidth, sqwidth, \ 256 - vdelay, sheight, videostart0) \ 257 + vdelay, sheight, extraheight, videostart0) \ 257 258 .cropcap.bounds.left = minhdelayx1, \ 258 259 /* * 2 because vertically we count field lines times two, */ \ 259 260 /* e.g. 23 * 2 to 23 * 2 + 576 in PAL-BGHI defrect. */ \ 260 261 .cropcap.bounds.top = (videostart0) * 2 - (vdelay) + MIN_VDELAY, \ 261 262 /* 4 is a safety margin at the end of the line. */ \ 262 263 .cropcap.bounds.width = (totalwidth) - (minhdelayx1) - 4, \ 263 - .cropcap.bounds.height = (sheight) + (vdelay) - MIN_VDELAY, \ 264 + .cropcap.bounds.height = (sheight) + (extraheight) + (vdelay) - \ 265 + MIN_VDELAY, \ 264 266 .cropcap.defrect.left = hdelayx1, \ 265 267 .cropcap.defrect.top = (videostart0) * 2, \ 266 268 .cropcap.defrect.width = swidth, \ ··· 303 301 /* totalwidth */ 1135, 304 302 /* sqwidth */ 944, 305 303 /* vdelay */ 0x20, 306 - /* bt878 (and bt848?) can capture another 307 - line below active video. */ 308 - /* sheight */ (576 + 2) + 0x20 - 2, 304 + /* sheight */ 576, 305 + /* bt878 (and bt848?) can capture another 306 + line below active video. */ 307 + /* extraheight */ 2, 309 308 /* videostart0 */ 23) 310 309 },{ 311 310 .v4l2_id = V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR, ··· 333 330 /* sqwidth */ 780, 334 331 /* vdelay */ 0x1a, 335 332 /* sheight */ 480, 333 + /* extraheight */ 0, 336 334 /* videostart0 */ 23) 337 335 },{ 338 336 .v4l2_id = V4L2_STD_SECAM, ··· 359 355 /* sqwidth */ 944, 360 356 /* vdelay */ 0x20, 361 357 /* sheight */ 576, 358 + /* extraheight */ 0, 362 359 /* videostart0 */ 23) 363 360 },{ 364 361 .v4l2_id = V4L2_STD_PAL_Nc, ··· 385 380 /* sqwidth */ 780, 386 381 /* vdelay */ 0x1a, 387 382 /* sheight */ 576, 383 + /* extraheight */ 0, 388 384 /* videostart0 */ 23) 389 385 },{ 390 386 .v4l2_id = V4L2_STD_PAL_M, ··· 411 405 /* sqwidth */ 780, 412 406 /* vdelay */ 0x1a, 413 407 /* sheight */ 480, 408 + /* extraheight */ 0, 414 409 /* videostart0 */ 23) 415 410 },{ 416 411 .v4l2_id = V4L2_STD_PAL_N, ··· 437 430 /* sqwidth */ 944, 438 431 /* vdelay */ 0x20, 439 432 /* sheight */ 576, 433 + /* extraheight */ 0, 440 434 /* videostart0 */ 23) 441 435 },{ 442 436 .v4l2_id = V4L2_STD_NTSC_M_JP, ··· 463 455 /* sqwidth */ 780, 464 456 /* vdelay */ 0x16, 465 457 /* sheight */ 480, 458 + /* extraheight */ 0, 466 459 /* videostart0 */ 23) 467 460 },{ 468 461 /* that one hopefully works with the strange timing ··· 493 484 /* sqwidth */ 944, 494 485 /* vdelay */ 0x1a, 495 486 /* sheight */ 480, 487 + /* extraheight */ 0, 496 488 /* videostart0 */ 23) 497 489 } 498 490 };