Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] v4l2: replace try_mbus_fmt by set_fmt

The try_mbus_fmt video op is a duplicate of the pad op. Replace all uses
in sub-devices by the set_fmt() pad op.

Since try_mbus_fmt and s_mbus_fmt both map to the set_fmt pad op (but
with a different 'which' argument), this patch will replace both
try_mbus_fmt and s_mbus_fmt by set_fmt.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kamil Debski <k.debski@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
717fd5b4 da298c6d

+304 -283
+18 -18
drivers/media/i2c/adv7183.c
··· 431 431 return 0; 432 432 } 433 433 434 - static int adv7183_try_mbus_fmt(struct v4l2_subdev *sd, 435 - struct v4l2_mbus_framefmt *fmt) 434 + static int adv7183_set_fmt(struct v4l2_subdev *sd, 435 + struct v4l2_subdev_pad_config *cfg, 436 + struct v4l2_subdev_format *format) 436 437 { 437 438 struct adv7183 *decoder = to_adv7183(sd); 439 + struct v4l2_mbus_framefmt *fmt = &format->format; 440 + 441 + if (format->pad) 442 + return -EINVAL; 438 443 439 444 fmt->code = MEDIA_BUS_FMT_UYVY8_2X8; 440 445 fmt->colorspace = V4L2_COLORSPACE_SMPTE170M; ··· 452 447 fmt->width = 720; 453 448 fmt->height = 576; 454 449 } 455 - return 0; 456 - } 457 - 458 - static int adv7183_s_mbus_fmt(struct v4l2_subdev *sd, 459 - struct v4l2_mbus_framefmt *fmt) 460 - { 461 - struct adv7183 *decoder = to_adv7183(sd); 462 - 463 - adv7183_try_mbus_fmt(sd, fmt); 464 - decoder->fmt = *fmt; 450 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 451 + decoder->fmt = *fmt; 452 + else 453 + cfg->try_fmt = *fmt; 465 454 return 0; 466 455 } 467 456 ··· 518 519 .s_routing = adv7183_s_routing, 519 520 .querystd = adv7183_querystd, 520 521 .g_input_status = adv7183_g_input_status, 521 - .try_mbus_fmt = adv7183_try_mbus_fmt, 522 - .s_mbus_fmt = adv7183_s_mbus_fmt, 523 522 .s_stream = adv7183_s_stream, 524 523 }; 525 524 526 525 static const struct v4l2_subdev_pad_ops adv7183_pad_ops = { 527 526 .enum_mbus_code = adv7183_enum_mbus_code, 528 527 .get_fmt = adv7183_get_fmt, 528 + .set_fmt = adv7183_set_fmt, 529 529 }; 530 530 531 531 static const struct v4l2_subdev_ops adv7183_ops = { ··· 540 542 struct v4l2_subdev *sd; 541 543 struct v4l2_ctrl_handler *hdl; 542 544 int ret; 543 - struct v4l2_mbus_framefmt fmt; 545 + struct v4l2_subdev_format fmt = { 546 + .which = V4L2_SUBDEV_FORMAT_ACTIVE, 547 + }; 544 548 const unsigned *pin_array; 545 549 546 550 /* Check if the adapter supports the needed features */ ··· 612 612 613 613 adv7183_writeregs(sd, adv7183_init_regs, ARRAY_SIZE(adv7183_init_regs)); 614 614 adv7183_s_std(sd, decoder->std); 615 - fmt.width = 720; 616 - fmt.height = 576; 617 - adv7183_s_mbus_fmt(sd, &fmt); 615 + fmt.format.width = 720; 616 + fmt.format.height = 576; 617 + adv7183_set_fmt(sd, NULL, &fmt); 618 618 619 619 /* initialize the hardware to the default control values */ 620 620 ret = v4l2_ctrl_handler_setup(hdl);
+17 -21
drivers/media/i2c/mt9v011.c
··· 335 335 return 0; 336 336 } 337 337 338 - static int mt9v011_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt) 338 + static int mt9v011_set_fmt(struct v4l2_subdev *sd, 339 + struct v4l2_subdev_pad_config *cfg, 340 + struct v4l2_subdev_format *format) 339 341 { 340 - if (fmt->code != MEDIA_BUS_FMT_SGRBG8_1X8) 342 + struct v4l2_mbus_framefmt *fmt = &format->format; 343 + struct mt9v011 *core = to_mt9v011(sd); 344 + 345 + if (format->pad || fmt->code != MEDIA_BUS_FMT_SGRBG8_1X8) 341 346 return -EINVAL; 342 347 343 348 v4l_bound_align_image(&fmt->width, 48, 639, 1, 344 349 &fmt->height, 32, 480, 1, 0); 345 350 fmt->field = V4L2_FIELD_NONE; 346 351 fmt->colorspace = V4L2_COLORSPACE_SRGB; 352 + 353 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) { 354 + core->width = fmt->width; 355 + core->height = fmt->height; 356 + 357 + set_res(sd); 358 + } else { 359 + cfg->try_fmt = *fmt; 360 + } 347 361 348 362 return 0; 349 363 } ··· 396 382 397 383 /* Recalculate and update fps info */ 398 384 calc_fps(sd, &tpf->numerator, &tpf->denominator); 399 - 400 - return 0; 401 - } 402 - 403 - static int mt9v011_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt) 404 - { 405 - struct mt9v011 *core = to_mt9v011(sd); 406 - int rc; 407 - 408 - rc = mt9v011_try_mbus_fmt(sd, fmt); 409 - if (rc < 0) 410 - return -EINVAL; 411 - 412 - core->width = fmt->width; 413 - core->height = fmt->height; 414 - 415 - set_res(sd); 416 385 417 386 return 0; 418 387 } ··· 467 470 }; 468 471 469 472 static const struct v4l2_subdev_video_ops mt9v011_video_ops = { 470 - .try_mbus_fmt = mt9v011_try_mbus_fmt, 471 - .s_mbus_fmt = mt9v011_s_mbus_fmt, 472 473 .g_parm = mt9v011_g_parm, 473 474 .s_parm = mt9v011_s_parm, 474 475 }; 475 476 476 477 static const struct v4l2_subdev_pad_ops mt9v011_pad_ops = { 477 478 .enum_mbus_code = mt9v011_enum_mbus_code, 479 + .set_fmt = mt9v011_set_fmt, 478 480 }; 479 481 480 482 static const struct v4l2_subdev_ops mt9v011_ops = {
+16 -11
drivers/media/i2c/ov7670.c
··· 971 971 return 0; 972 972 } 973 973 974 - static int ov7670_try_mbus_fmt(struct v4l2_subdev *sd, 975 - struct v4l2_mbus_framefmt *fmt) 976 - { 977 - return ov7670_try_fmt_internal(sd, fmt, NULL, NULL); 978 - } 979 - 980 974 /* 981 975 * Set a format. 982 976 */ 983 - static int ov7670_s_mbus_fmt(struct v4l2_subdev *sd, 984 - struct v4l2_mbus_framefmt *fmt) 977 + static int ov7670_set_fmt(struct v4l2_subdev *sd, 978 + struct v4l2_subdev_pad_config *cfg, 979 + struct v4l2_subdev_format *format) 985 980 { 986 981 struct ov7670_format_struct *ovfmt; 987 982 struct ov7670_win_size *wsize; ··· 984 989 unsigned char com7; 985 990 int ret; 986 991 987 - ret = ov7670_try_fmt_internal(sd, fmt, &ovfmt, &wsize); 992 + if (format->pad) 993 + return -EINVAL; 994 + 995 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 996 + ret = ov7670_try_fmt_internal(sd, &format->format, NULL, NULL); 997 + if (ret) 998 + return ret; 999 + cfg->try_fmt = format->format; 1000 + return 0; 1001 + } 1002 + 1003 + ret = ov7670_try_fmt_internal(sd, &format->format, &ovfmt, &wsize); 988 1004 989 1005 if (ret) 990 1006 return ret; ··· 1515 1509 }; 1516 1510 1517 1511 static const struct v4l2_subdev_video_ops ov7670_video_ops = { 1518 - .try_mbus_fmt = ov7670_try_mbus_fmt, 1519 - .s_mbus_fmt = ov7670_s_mbus_fmt, 1520 1512 .s_parm = ov7670_s_parm, 1521 1513 .g_parm = ov7670_g_parm, 1522 1514 }; ··· 1523 1519 .enum_frame_interval = ov7670_enum_frame_interval, 1524 1520 .enum_frame_size = ov7670_enum_frame_size, 1525 1521 .enum_mbus_code = ov7670_enum_mbus_code, 1522 + .set_fmt = ov7670_set_fmt, 1526 1523 }; 1527 1524 1528 1525 static const struct v4l2_subdev_ops ov7670_ops = {
+16 -12
drivers/media/i2c/saa6752hs.c
··· 574 574 return 0; 575 575 } 576 576 577 - static int saa6752hs_try_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f) 577 + static int saa6752hs_set_fmt(struct v4l2_subdev *sd, 578 + struct v4l2_subdev_pad_config *cfg, 579 + struct v4l2_subdev_format *format) 578 580 { 581 + struct v4l2_mbus_framefmt *f = &format->format; 582 + struct saa6752hs_state *h = to_state(sd); 579 583 int dist_352, dist_480, dist_720; 584 + 585 + if (format->pad) 586 + return -EINVAL; 580 587 581 588 f->code = MEDIA_BUS_FMT_FIXED; 582 589 ··· 605 598 } 606 599 f->field = V4L2_FIELD_INTERLACED; 607 600 f->colorspace = V4L2_COLORSPACE_SMPTE170M; 608 - return 0; 609 - } 610 601 611 - static int saa6752hs_s_mbus_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *f) 612 - { 613 - struct saa6752hs_state *h = to_state(sd); 614 - 615 - if (f->code != MEDIA_BUS_FMT_FIXED) 616 - return -EINVAL; 602 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 603 + cfg->try_fmt = *f; 604 + return 0; 605 + } 617 606 618 607 /* 619 608 FIXME: translate and round width/height into EMPRESS ··· 623 620 D1 | 720x576 | 720x480 624 621 */ 625 622 626 - saa6752hs_try_mbus_fmt(sd, f); 623 + if (f->code != MEDIA_BUS_FMT_FIXED) 624 + return -EINVAL; 625 + 627 626 if (f->width == 720) 628 627 h->video_format = SAA6752HS_VF_D1; 629 628 else if (f->width == 480) ··· 658 653 659 654 static const struct v4l2_subdev_video_ops saa6752hs_video_ops = { 660 655 .s_std = saa6752hs_s_std, 661 - .s_mbus_fmt = saa6752hs_s_mbus_fmt, 662 - .try_mbus_fmt = saa6752hs_try_mbus_fmt, 663 656 }; 664 657 665 658 static const struct v4l2_subdev_pad_ops saa6752hs_pad_ops = { 666 659 .get_fmt = saa6752hs_get_fmt, 660 + .set_fmt = saa6752hs_set_fmt, 667 661 }; 668 662 669 663 static const struct v4l2_subdev_ops saa6752hs_ops = {
+17 -22
drivers/media/i2c/soc_camera/imx074.c
··· 153 153 return buf[0] & 0xff; /* no sign-extension */ 154 154 } 155 155 156 - static int imx074_try_fmt(struct v4l2_subdev *sd, 157 - struct v4l2_mbus_framefmt *mf) 156 + static int imx074_set_fmt(struct v4l2_subdev *sd, 157 + struct v4l2_subdev_pad_config *cfg, 158 + struct v4l2_subdev_format *format) 158 159 { 160 + struct v4l2_mbus_framefmt *mf = &format->format; 159 161 const struct imx074_datafmt *fmt = imx074_find_datafmt(mf->code); 162 + struct i2c_client *client = v4l2_get_subdevdata(sd); 163 + struct imx074 *priv = to_imx074(client); 164 + 165 + if (format->pad) 166 + return -EINVAL; 160 167 161 168 dev_dbg(sd->v4l2_dev->dev, "%s(%u)\n", __func__, mf->code); 162 169 163 170 if (!fmt) { 171 + /* MIPI CSI could have changed the format, double-check */ 172 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 173 + return -EINVAL; 164 174 mf->code = imx074_colour_fmts[0].code; 165 175 mf->colorspace = imx074_colour_fmts[0].colorspace; 166 176 } ··· 179 169 mf->height = IMX074_HEIGHT; 180 170 mf->field = V4L2_FIELD_NONE; 181 171 182 - return 0; 183 - } 184 - 185 - static int imx074_s_fmt(struct v4l2_subdev *sd, 186 - struct v4l2_mbus_framefmt *mf) 187 - { 188 - struct i2c_client *client = v4l2_get_subdevdata(sd); 189 - struct imx074 *priv = to_imx074(client); 190 - 191 - dev_dbg(sd->v4l2_dev->dev, "%s(%u)\n", __func__, mf->code); 192 - 193 - /* MIPI CSI could have changed the format, double-check */ 194 - if (!imx074_find_datafmt(mf->code)) 195 - return -EINVAL; 196 - 197 - imx074_try_fmt(sd, mf); 198 - 199 - priv->fmt = imx074_find_datafmt(mf->code); 172 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 173 + priv->fmt = imx074_find_datafmt(mf->code); 174 + else 175 + cfg->try_fmt = *mf; 200 176 201 177 return 0; 202 178 } ··· 278 282 279 283 static struct v4l2_subdev_video_ops imx074_subdev_video_ops = { 280 284 .s_stream = imx074_s_stream, 281 - .s_mbus_fmt = imx074_s_fmt, 282 - .try_mbus_fmt = imx074_try_fmt, 283 285 .g_crop = imx074_g_crop, 284 286 .cropcap = imx074_cropcap, 285 287 .g_mbus_config = imx074_g_mbus_config, ··· 290 296 static const struct v4l2_subdev_pad_ops imx074_subdev_pad_ops = { 291 297 .enum_mbus_code = imx074_enum_mbus_code, 292 298 .get_fmt = imx074_get_fmt, 299 + .set_fmt = imx074_set_fmt, 293 300 }; 294 301 295 302 static struct v4l2_subdev_ops imx074_subdev_ops = {
+12 -5
drivers/media/i2c/soc_camera/mt9m001.c
··· 205 205 206 206 /* 207 207 * The caller provides a supported format, as verified per 208 - * call to .try_mbus_fmt() 208 + * call to .set_fmt(FORMAT_TRY). 209 209 */ 210 210 if (!ret) 211 211 ret = reg_write(client, MT9M001_COLUMN_START, rect.left); ··· 298 298 return ret; 299 299 } 300 300 301 - static int mt9m001_try_fmt(struct v4l2_subdev *sd, 302 - struct v4l2_mbus_framefmt *mf) 301 + static int mt9m001_set_fmt(struct v4l2_subdev *sd, 302 + struct v4l2_subdev_pad_config *cfg, 303 + struct v4l2_subdev_format *format) 303 304 { 305 + struct v4l2_mbus_framefmt *mf = &format->format; 304 306 struct i2c_client *client = v4l2_get_subdevdata(sd); 305 307 struct mt9m001 *mt9m001 = to_mt9m001(client); 306 308 const struct mt9m001_datafmt *fmt; 309 + 310 + if (format->pad) 311 + return -EINVAL; 307 312 308 313 v4l_bound_align_image(&mf->width, MT9M001_MIN_WIDTH, 309 314 MT9M001_MAX_WIDTH, 1, ··· 327 322 328 323 mf->colorspace = fmt->colorspace; 329 324 325 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 326 + return mt9m001_s_fmt(sd, mf); 327 + cfg->try_fmt = *mf; 330 328 return 0; 331 329 } 332 330 ··· 625 617 626 618 static struct v4l2_subdev_video_ops mt9m001_subdev_video_ops = { 627 619 .s_stream = mt9m001_s_stream, 628 - .s_mbus_fmt = mt9m001_s_fmt, 629 - .try_mbus_fmt = mt9m001_try_fmt, 630 620 .s_crop = mt9m001_s_crop, 631 621 .g_crop = mt9m001_g_crop, 632 622 .cropcap = mt9m001_cropcap, ··· 639 633 static const struct v4l2_subdev_pad_ops mt9m001_subdev_pad_ops = { 640 634 .enum_mbus_code = mt9m001_enum_mbus_code, 641 635 .get_fmt = mt9m001_get_fmt, 636 + .set_fmt = mt9m001_set_fmt, 642 637 }; 643 638 644 639 static struct v4l2_subdev_ops mt9m001_subdev_ops = {
+13 -18
drivers/media/i2c/soc_camera/mt9m111.c
··· 536 536 return ret; 537 537 } 538 538 539 - static int mt9m111_try_fmt(struct v4l2_subdev *sd, 540 - struct v4l2_mbus_framefmt *mf) 539 + static int mt9m111_set_fmt(struct v4l2_subdev *sd, 540 + struct v4l2_subdev_pad_config *cfg, 541 + struct v4l2_subdev_format *format) 541 542 { 543 + struct v4l2_mbus_framefmt *mf = &format->format; 542 544 struct i2c_client *client = v4l2_get_subdevdata(sd); 543 545 struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); 544 546 const struct mt9m111_datafmt *fmt; 545 547 struct v4l2_rect *rect = &mt9m111->rect; 546 548 bool bayer; 549 + int ret; 550 + 551 + if (format->pad) 552 + return -EINVAL; 547 553 548 554 fmt = mt9m111_find_datafmt(mt9m111, mf->code); 549 555 ··· 583 577 mf->code = fmt->code; 584 578 mf->colorspace = fmt->colorspace; 585 579 586 - return 0; 587 - } 588 - 589 - static int mt9m111_s_fmt(struct v4l2_subdev *sd, 590 - struct v4l2_mbus_framefmt *mf) 591 - { 592 - const struct mt9m111_datafmt *fmt; 593 - struct mt9m111 *mt9m111 = container_of(sd, struct mt9m111, subdev); 594 - struct v4l2_rect *rect = &mt9m111->rect; 595 - int ret; 596 - 597 - mt9m111_try_fmt(sd, mf); 598 - fmt = mt9m111_find_datafmt(mt9m111, mf->code); 599 - /* try_fmt() guarantees fmt != NULL && fmt->code == mf->code */ 580 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 581 + cfg->try_fmt = *mf; 582 + return 0; 583 + } 600 584 601 585 ret = mt9m111_setup_geometry(mt9m111, rect, mf->width, mf->height, mf->code); 602 586 if (!ret) ··· 867 871 } 868 872 869 873 static struct v4l2_subdev_video_ops mt9m111_subdev_video_ops = { 870 - .s_mbus_fmt = mt9m111_s_fmt, 871 - .try_mbus_fmt = mt9m111_try_fmt, 872 874 .s_crop = mt9m111_s_crop, 873 875 .g_crop = mt9m111_g_crop, 874 876 .cropcap = mt9m111_cropcap, ··· 876 882 static const struct v4l2_subdev_pad_ops mt9m111_subdev_pad_ops = { 877 883 .enum_mbus_code = mt9m111_enum_mbus_code, 878 884 .get_fmt = mt9m111_get_fmt, 885 + .set_fmt = mt9m111_set_fmt, 879 886 }; 880 887 881 888 static struct v4l2_subdev_ops mt9m111_subdev_ops = {
+25 -23
drivers/media/i2c/soc_camera/mt9t031.c
··· 264 264 265 265 /* 266 266 * The caller provides a supported format, as guaranteed by 267 - * .try_mbus_fmt(), soc_camera_s_crop() and soc_camera_cropcap() 267 + * .set_fmt(FORMAT_TRY), soc_camera_s_crop() and soc_camera_cropcap() 268 268 */ 269 269 if (ret >= 0) 270 270 ret = reg_write(client, MT9T031_COLUMN_START, rect->left); ··· 357 357 return 0; 358 358 } 359 359 360 - static int mt9t031_s_fmt(struct v4l2_subdev *sd, 361 - struct v4l2_mbus_framefmt *mf) 360 + /* 361 + * If a user window larger than sensor window is requested, we'll increase the 362 + * sensor window. 363 + */ 364 + static int mt9t031_set_fmt(struct v4l2_subdev *sd, 365 + struct v4l2_subdev_pad_config *cfg, 366 + struct v4l2_subdev_format *format) 362 367 { 368 + struct v4l2_mbus_framefmt *mf = &format->format; 363 369 struct i2c_client *client = v4l2_get_subdevdata(sd); 364 370 struct mt9t031 *mt9t031 = to_mt9t031(client); 365 371 u16 xskip, yskip; 366 372 struct v4l2_rect rect = mt9t031->rect; 367 373 374 + if (format->pad) 375 + return -EINVAL; 376 + 377 + mf->code = MEDIA_BUS_FMT_SBGGR10_1X10; 378 + mf->colorspace = V4L2_COLORSPACE_SRGB; 379 + v4l_bound_align_image( 380 + &mf->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1, 381 + &mf->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0); 382 + 383 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 384 + cfg->try_fmt = *mf; 385 + return 0; 386 + } 387 + 368 388 /* 369 - * try_fmt has put width and height within limits. 389 + * Width and height are within limits. 370 390 * S_FMT: use binning and skipping for scaling 371 391 */ 372 392 xskip = mt9t031_skip(&rect.width, mf->width, MT9T031_MAX_WIDTH); ··· 397 377 398 378 /* mt9t031_set_params() doesn't change width and height */ 399 379 return mt9t031_set_params(client, &rect, xskip, yskip); 400 - } 401 - 402 - /* 403 - * If a user window larger than sensor window is requested, we'll increase the 404 - * sensor window. 405 - */ 406 - static int mt9t031_try_fmt(struct v4l2_subdev *sd, 407 - struct v4l2_mbus_framefmt *mf) 408 - { 409 - v4l_bound_align_image( 410 - &mf->width, MT9T031_MIN_WIDTH, MT9T031_MAX_WIDTH, 1, 411 - &mf->height, MT9T031_MIN_HEIGHT, MT9T031_MAX_HEIGHT, 1, 0); 412 - 413 - mf->code = MEDIA_BUS_FMT_SBGGR10_1X10; 414 - mf->colorspace = V4L2_COLORSPACE_SRGB; 415 - 416 - return 0; 417 380 } 418 381 419 382 #ifdef CONFIG_VIDEO_ADV_DEBUG ··· 721 718 722 719 static struct v4l2_subdev_video_ops mt9t031_subdev_video_ops = { 723 720 .s_stream = mt9t031_s_stream, 724 - .s_mbus_fmt = mt9t031_s_fmt, 725 - .try_mbus_fmt = mt9t031_try_fmt, 726 721 .s_crop = mt9t031_s_crop, 727 722 .g_crop = mt9t031_g_crop, 728 723 .cropcap = mt9t031_cropcap, ··· 735 734 static const struct v4l2_subdev_pad_ops mt9t031_subdev_pad_ops = { 736 735 .enum_mbus_code = mt9t031_enum_mbus_code, 737 736 .get_fmt = mt9t031_get_fmt, 737 + .set_fmt = mt9t031_set_fmt, 738 738 }; 739 739 740 740 static struct v4l2_subdev_ops mt9t031_subdev_ops = {
+11 -4
drivers/media/i2c/soc_camera/mt9t112.c
··· 945 945 return ret; 946 946 } 947 947 948 - static int mt9t112_try_fmt(struct v4l2_subdev *sd, 949 - struct v4l2_mbus_framefmt *mf) 948 + static int mt9t112_set_fmt(struct v4l2_subdev *sd, 949 + struct v4l2_subdev_pad_config *cfg, 950 + struct v4l2_subdev_format *format) 950 951 { 952 + struct v4l2_mbus_framefmt *mf = &format->format; 951 953 struct i2c_client *client = v4l2_get_subdevdata(sd); 952 954 struct mt9t112_priv *priv = to_mt9t112(client); 953 955 unsigned int top, left; 954 956 int i; 957 + 958 + if (format->pad) 959 + return -EINVAL; 955 960 956 961 for (i = 0; i < priv->num_formats; i++) 957 962 if (mt9t112_cfmts[i].code == mf->code) ··· 973 968 974 969 mf->field = V4L2_FIELD_NONE; 975 970 971 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 972 + return mt9t112_s_fmt(sd, mf); 973 + cfg->try_fmt = *mf; 976 974 return 0; 977 975 } 978 976 ··· 1024 1016 1025 1017 static struct v4l2_subdev_video_ops mt9t112_subdev_video_ops = { 1026 1018 .s_stream = mt9t112_s_stream, 1027 - .s_mbus_fmt = mt9t112_s_fmt, 1028 - .try_mbus_fmt = mt9t112_try_fmt, 1029 1019 .cropcap = mt9t112_cropcap, 1030 1020 .g_crop = mt9t112_g_crop, 1031 1021 .s_crop = mt9t112_s_crop, ··· 1034 1028 static const struct v4l2_subdev_pad_ops mt9t112_subdev_pad_ops = { 1035 1029 .enum_mbus_code = mt9t112_enum_mbus_code, 1036 1030 .get_fmt = mt9t112_get_fmt, 1031 + .set_fmt = mt9t112_set_fmt, 1037 1032 }; 1038 1033 1039 1034 /************************************************************************
+12 -5
drivers/media/i2c/soc_camera/mt9v022.c
··· 412 412 413 413 /* 414 414 * The caller provides a supported format, as verified per call to 415 - * .try_mbus_fmt(), datawidth is from our supported format list 415 + * .set_fmt(FORMAT_TRY), datawidth is from our supported format list 416 416 */ 417 417 switch (mf->code) { 418 418 case MEDIA_BUS_FMT_Y8_1X8: ··· 442 442 return ret; 443 443 } 444 444 445 - static int mt9v022_try_fmt(struct v4l2_subdev *sd, 446 - struct v4l2_mbus_framefmt *mf) 445 + static int mt9v022_set_fmt(struct v4l2_subdev *sd, 446 + struct v4l2_subdev_pad_config *cfg, 447 + struct v4l2_subdev_format *format) 447 448 { 449 + struct v4l2_mbus_framefmt *mf = &format->format; 448 450 struct i2c_client *client = v4l2_get_subdevdata(sd); 449 451 struct mt9v022 *mt9v022 = to_mt9v022(client); 450 452 const struct mt9v022_datafmt *fmt; 451 453 int align = mf->code == MEDIA_BUS_FMT_SBGGR8_1X8 || 452 454 mf->code == MEDIA_BUS_FMT_SBGGR10_1X10; 455 + 456 + if (format->pad) 457 + return -EINVAL; 453 458 454 459 v4l_bound_align_image(&mf->width, MT9V022_MIN_WIDTH, 455 460 MT9V022_MAX_WIDTH, align, ··· 470 465 471 466 mf->colorspace = fmt->colorspace; 472 467 468 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 469 + return mt9v022_s_fmt(sd, mf); 470 + cfg->try_fmt = *mf; 473 471 return 0; 474 472 } 475 473 ··· 853 845 854 846 static struct v4l2_subdev_video_ops mt9v022_subdev_video_ops = { 855 847 .s_stream = mt9v022_s_stream, 856 - .s_mbus_fmt = mt9v022_s_fmt, 857 - .try_mbus_fmt = mt9v022_try_fmt, 858 848 .s_crop = mt9v022_s_crop, 859 849 .g_crop = mt9v022_g_crop, 860 850 .cropcap = mt9v022_cropcap, ··· 867 861 static const struct v4l2_subdev_pad_ops mt9v022_subdev_pad_ops = { 868 862 .enum_mbus_code = mt9v022_enum_mbus_code, 869 863 .get_fmt = mt9v022_get_fmt, 864 + .set_fmt = mt9v022_set_fmt, 870 865 }; 871 866 872 867 static struct v4l2_subdev_ops mt9v022_subdev_ops = {
+11 -25
drivers/media/i2c/soc_camera/ov2640.c
··· 881 881 return 0; 882 882 } 883 883 884 - static int ov2640_s_fmt(struct v4l2_subdev *sd, 885 - struct v4l2_mbus_framefmt *mf) 884 + static int ov2640_set_fmt(struct v4l2_subdev *sd, 885 + struct v4l2_subdev_pad_config *cfg, 886 + struct v4l2_subdev_format *format) 886 887 { 888 + struct v4l2_mbus_framefmt *mf = &format->format; 887 889 struct i2c_client *client = v4l2_get_subdevdata(sd); 888 - int ret; 889 890 891 + if (format->pad) 892 + return -EINVAL; 890 893 891 - switch (mf->code) { 892 - case MEDIA_BUS_FMT_RGB565_2X8_BE: 893 - case MEDIA_BUS_FMT_RGB565_2X8_LE: 894 - mf->colorspace = V4L2_COLORSPACE_SRGB; 895 - break; 896 - default: 897 - mf->code = MEDIA_BUS_FMT_UYVY8_2X8; 898 - case MEDIA_BUS_FMT_YUYV8_2X8: 899 - case MEDIA_BUS_FMT_UYVY8_2X8: 900 - mf->colorspace = V4L2_COLORSPACE_JPEG; 901 - } 902 - 903 - ret = ov2640_set_params(client, &mf->width, &mf->height, mf->code); 904 - 905 - return ret; 906 - } 907 - 908 - static int ov2640_try_fmt(struct v4l2_subdev *sd, 909 - struct v4l2_mbus_framefmt *mf) 910 - { 911 894 /* 912 895 * select suitable win, but don't store it 913 896 */ ··· 910 927 mf->colorspace = V4L2_COLORSPACE_JPEG; 911 928 } 912 929 930 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 931 + return ov2640_set_params(client, &mf->width, 932 + &mf->height, mf->code); 933 + cfg->try_fmt = *mf; 913 934 return 0; 914 935 } 915 936 ··· 1024 1037 1025 1038 static struct v4l2_subdev_video_ops ov2640_subdev_video_ops = { 1026 1039 .s_stream = ov2640_s_stream, 1027 - .s_mbus_fmt = ov2640_s_fmt, 1028 - .try_mbus_fmt = ov2640_try_fmt, 1029 1040 .cropcap = ov2640_cropcap, 1030 1041 .g_crop = ov2640_g_crop, 1031 1042 .g_mbus_config = ov2640_g_mbus_config, ··· 1032 1047 static const struct v4l2_subdev_pad_ops ov2640_subdev_pad_ops = { 1033 1048 .enum_mbus_code = ov2640_enum_mbus_code, 1034 1049 .get_fmt = ov2640_get_fmt, 1050 + .set_fmt = ov2640_set_fmt, 1035 1051 }; 1036 1052 1037 1053 static struct v4l2_subdev_ops ov2640_subdev_ops = {
+14 -20
drivers/media/i2c/soc_camera/ov5642.c
··· 786 786 return ret; 787 787 } 788 788 789 - static int ov5642_try_fmt(struct v4l2_subdev *sd, 790 - struct v4l2_mbus_framefmt *mf) 789 + static int ov5642_set_fmt(struct v4l2_subdev *sd, 790 + struct v4l2_subdev_pad_config *cfg, 791 + struct v4l2_subdev_format *format) 791 792 { 793 + struct v4l2_mbus_framefmt *mf = &format->format; 792 794 struct i2c_client *client = v4l2_get_subdevdata(sd); 793 795 struct ov5642 *priv = to_ov5642(client); 794 796 const struct ov5642_datafmt *fmt = ov5642_find_datafmt(mf->code); 797 + 798 + if (format->pad) 799 + return -EINVAL; 795 800 796 801 mf->width = priv->crop_rect.width; 797 802 mf->height = priv->crop_rect.height; 798 803 799 804 if (!fmt) { 805 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 806 + return -EINVAL; 800 807 mf->code = ov5642_colour_fmts[0].code; 801 808 mf->colorspace = ov5642_colour_fmts[0].colorspace; 802 809 } 803 810 804 811 mf->field = V4L2_FIELD_NONE; 805 812 806 - return 0; 807 - } 808 - 809 - static int ov5642_s_fmt(struct v4l2_subdev *sd, 810 - struct v4l2_mbus_framefmt *mf) 811 - { 812 - struct i2c_client *client = v4l2_get_subdevdata(sd); 813 - struct ov5642 *priv = to_ov5642(client); 814 - 815 - /* MIPI CSI could have changed the format, double-check */ 816 - if (!ov5642_find_datafmt(mf->code)) 817 - return -EINVAL; 818 - 819 - ov5642_try_fmt(sd, mf); 820 - priv->fmt = ov5642_find_datafmt(mf->code); 821 - 813 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 814 + priv->fmt = ov5642_find_datafmt(mf->code); 815 + else 816 + cfg->try_fmt = *mf; 822 817 return 0; 823 818 } 824 819 ··· 940 945 } 941 946 942 947 static struct v4l2_subdev_video_ops ov5642_subdev_video_ops = { 943 - .s_mbus_fmt = ov5642_s_fmt, 944 - .try_mbus_fmt = ov5642_try_fmt, 945 948 .s_crop = ov5642_s_crop, 946 949 .g_crop = ov5642_g_crop, 947 950 .cropcap = ov5642_cropcap, ··· 949 956 static const struct v4l2_subdev_pad_ops ov5642_subdev_pad_ops = { 950 957 .enum_mbus_code = ov5642_enum_mbus_code, 951 958 .get_fmt = ov5642_get_fmt, 959 + .set_fmt = ov5642_set_fmt, 952 960 }; 953 961 954 962 static struct v4l2_subdev_core_ops ov5642_subdev_core_ops = {
+12 -5
drivers/media/i2c/soc_camera/ov6650.c
··· 685 685 mf->width = priv->rect.width >> half_scale; 686 686 mf->height = priv->rect.height >> half_scale; 687 687 } 688 - 689 688 return ret; 690 689 } 691 690 692 - static int ov6650_try_fmt(struct v4l2_subdev *sd, 693 - struct v4l2_mbus_framefmt *mf) 691 + static int ov6650_set_fmt(struct v4l2_subdev *sd, 692 + struct v4l2_subdev_pad_config *cfg, 693 + struct v4l2_subdev_format *format) 694 694 { 695 + struct v4l2_mbus_framefmt *mf = &format->format; 695 696 struct i2c_client *client = v4l2_get_subdevdata(sd); 696 697 struct ov6650 *priv = to_ov6650(client); 698 + 699 + if (format->pad) 700 + return -EINVAL; 697 701 698 702 if (is_unscaled_ok(mf->width, mf->height, &priv->rect)) 699 703 v4l_bound_align_image(&mf->width, 2, W_CIF, 1, ··· 721 717 mf->colorspace = V4L2_COLORSPACE_SRGB; 722 718 break; 723 719 } 720 + 721 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 722 + return ov6650_s_fmt(sd, mf); 723 + cfg->try_fmt = *mf; 724 724 725 725 return 0; 726 726 } ··· 943 935 944 936 static struct v4l2_subdev_video_ops ov6650_video_ops = { 945 937 .s_stream = ov6650_s_stream, 946 - .s_mbus_fmt = ov6650_s_fmt, 947 - .try_mbus_fmt = ov6650_try_fmt, 948 938 .cropcap = ov6650_cropcap, 949 939 .g_crop = ov6650_g_crop, 950 940 .s_crop = ov6650_s_crop, ··· 955 949 static const struct v4l2_subdev_pad_ops ov6650_pad_ops = { 956 950 .enum_mbus_code = ov6650_enum_mbus_code, 957 951 .get_fmt = ov6650_get_fmt, 952 + .set_fmt = ov6650_set_fmt, 958 953 }; 959 954 960 955 static struct v4l2_subdev_ops ov6650_subdev_ops = {
+11 -4
drivers/media/i2c/soc_camera/ov772x.c
··· 920 920 return 0; 921 921 } 922 922 923 - static int ov772x_try_fmt(struct v4l2_subdev *sd, 924 - struct v4l2_mbus_framefmt *mf) 923 + static int ov772x_set_fmt(struct v4l2_subdev *sd, 924 + struct v4l2_subdev_pad_config *cfg, 925 + struct v4l2_subdev_format *format) 925 926 { 927 + struct v4l2_mbus_framefmt *mf = &format->format; 926 928 const struct ov772x_color_format *cfmt; 927 929 const struct ov772x_win_size *win; 930 + 931 + if (format->pad) 932 + return -EINVAL; 928 933 929 934 ov772x_select_params(mf, &cfmt, &win); 930 935 ··· 939 934 mf->field = V4L2_FIELD_NONE; 940 935 mf->colorspace = cfmt->colorspace; 941 936 937 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 938 + return ov772x_s_fmt(sd, mf); 939 + cfg->try_fmt = *mf; 942 940 return 0; 943 941 } 944 942 ··· 1030 1022 1031 1023 static struct v4l2_subdev_video_ops ov772x_subdev_video_ops = { 1032 1024 .s_stream = ov772x_s_stream, 1033 - .s_mbus_fmt = ov772x_s_fmt, 1034 - .try_mbus_fmt = ov772x_try_fmt, 1035 1025 .cropcap = ov772x_cropcap, 1036 1026 .g_crop = ov772x_g_crop, 1037 1027 .g_mbus_config = ov772x_g_mbus_config, ··· 1038 1032 static const struct v4l2_subdev_pad_ops ov772x_subdev_pad_ops = { 1039 1033 .enum_mbus_code = ov772x_enum_mbus_code, 1040 1034 .get_fmt = ov772x_get_fmt, 1035 + .set_fmt = ov772x_set_fmt, 1041 1036 }; 1042 1037 1043 1038 static struct v4l2_subdev_ops ov772x_subdev_ops = {
+13 -4
drivers/media/i2c/soc_camera/ov9640.c
··· 519 519 return ret; 520 520 } 521 521 522 - static int ov9640_try_fmt(struct v4l2_subdev *sd, 523 - struct v4l2_mbus_framefmt *mf) 522 + static int ov9640_set_fmt(struct v4l2_subdev *sd, 523 + struct v4l2_subdev_pad_config *cfg, 524 + struct v4l2_subdev_format *format) 524 525 { 526 + struct v4l2_mbus_framefmt *mf = &format->format; 527 + 528 + if (format->pad) 529 + return -EINVAL; 530 + 525 531 ov9640_res_roundup(&mf->width, &mf->height); 526 532 527 533 mf->field = V4L2_FIELD_NONE; ··· 543 537 mf->colorspace = V4L2_COLORSPACE_JPEG; 544 538 } 545 539 540 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 541 + return ov9640_s_fmt(sd, mf); 542 + 543 + cfg->try_fmt = *mf; 546 544 return 0; 547 545 } 548 546 ··· 667 657 668 658 static struct v4l2_subdev_video_ops ov9640_video_ops = { 669 659 .s_stream = ov9640_s_stream, 670 - .s_mbus_fmt = ov9640_s_fmt, 671 - .try_mbus_fmt = ov9640_try_fmt, 672 660 .cropcap = ov9640_cropcap, 673 661 .g_crop = ov9640_g_crop, 674 662 .g_mbus_config = ov9640_g_mbus_config, ··· 674 666 675 667 static const struct v4l2_subdev_pad_ops ov9640_pad_ops = { 676 668 .enum_mbus_code = ov9640_enum_mbus_code, 669 + .set_fmt = ov9640_set_fmt, 677 670 }; 678 671 679 672 static struct v4l2_subdev_ops ov9640_subdev_ops = {
+12 -4
drivers/media/i2c/soc_camera/ov9740.c
··· 704 704 return ret; 705 705 } 706 706 707 - static int ov9740_try_fmt(struct v4l2_subdev *sd, 708 - struct v4l2_mbus_framefmt *mf) 707 + static int ov9740_set_fmt(struct v4l2_subdev *sd, 708 + struct v4l2_subdev_pad_config *cfg, 709 + struct v4l2_subdev_format *format) 709 710 { 711 + struct v4l2_mbus_framefmt *mf = &format->format; 712 + 713 + if (format->pad) 714 + return -EINVAL; 715 + 710 716 ov9740_res_roundup(&mf->width, &mf->height); 711 717 712 718 mf->field = V4L2_FIELD_NONE; 713 719 mf->code = MEDIA_BUS_FMT_YUYV8_2X8; 714 720 mf->colorspace = V4L2_COLORSPACE_SRGB; 715 721 722 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 723 + return ov9740_s_fmt(sd, mf); 724 + cfg->try_fmt = *mf; 716 725 return 0; 717 726 } 718 727 ··· 914 905 915 906 static struct v4l2_subdev_video_ops ov9740_video_ops = { 916 907 .s_stream = ov9740_s_stream, 917 - .s_mbus_fmt = ov9740_s_fmt, 918 - .try_mbus_fmt = ov9740_try_fmt, 919 908 .cropcap = ov9740_cropcap, 920 909 .g_crop = ov9740_g_crop, 921 910 .g_mbus_config = ov9740_g_mbus_config, ··· 929 922 930 923 static const struct v4l2_subdev_pad_ops ov9740_pad_ops = { 931 924 .enum_mbus_code = ov9740_enum_mbus_code, 925 + .set_fmt = ov9740_set_fmt, 932 926 }; 933 927 934 928 static struct v4l2_subdev_ops ov9740_subdev_ops = {
+15 -25
drivers/media/i2c/soc_camera/rj54n1cb0c.c
··· 965 965 return ret; 966 966 } 967 967 968 - static int rj54n1_try_fmt(struct v4l2_subdev *sd, 969 - struct v4l2_mbus_framefmt *mf) 968 + static int rj54n1_set_fmt(struct v4l2_subdev *sd, 969 + struct v4l2_subdev_pad_config *cfg, 970 + struct v4l2_subdev_format *format) 970 971 { 972 + struct v4l2_mbus_framefmt *mf = &format->format; 971 973 struct i2c_client *client = v4l2_get_subdevdata(sd); 972 974 struct rj54n1 *rj54n1 = to_rj54n1(client); 973 975 const struct rj54n1_datafmt *fmt; 976 + int output_w, output_h, max_w, max_h, 977 + input_w = rj54n1->rect.width, input_h = rj54n1->rect.height; 974 978 int align = mf->code == MEDIA_BUS_FMT_SBGGR10_1X10 || 975 979 mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE || 976 980 mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE || 977 981 mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE || 978 982 mf->code == MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE; 983 + int ret; 984 + 985 + if (format->pad) 986 + return -EINVAL; 979 987 980 988 dev_dbg(&client->dev, "%s: code = %d, width = %u, height = %u\n", 981 989 __func__, mf->code, mf->width, mf->height); ··· 1001 993 v4l_bound_align_image(&mf->width, 112, RJ54N1_MAX_WIDTH, align, 1002 994 &mf->height, 84, RJ54N1_MAX_HEIGHT, align, 0); 1003 995 1004 - return 0; 1005 - } 1006 - 1007 - static int rj54n1_s_fmt(struct v4l2_subdev *sd, 1008 - struct v4l2_mbus_framefmt *mf) 1009 - { 1010 - struct i2c_client *client = v4l2_get_subdevdata(sd); 1011 - struct rj54n1 *rj54n1 = to_rj54n1(client); 1012 - const struct rj54n1_datafmt *fmt; 1013 - int output_w, output_h, max_w, max_h, 1014 - input_w = rj54n1->rect.width, input_h = rj54n1->rect.height; 1015 - int ret; 1016 - 1017 - /* 1018 - * The host driver can call us without .try_fmt(), so, we have to take 1019 - * care ourseleves 1020 - */ 1021 - rj54n1_try_fmt(sd, mf); 996 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 997 + cfg->try_fmt = *mf; 998 + return 0; 999 + } 1022 1000 1023 1001 /* 1024 1002 * Verify if the sensor has just been powered on. TODO: replace this ··· 1019 1025 if (ret < 0) 1020 1026 return ret; 1021 1027 } 1022 - 1023 - dev_dbg(&client->dev, "%s: code = %d, width = %u, height = %u\n", 1024 - __func__, mf->code, mf->width, mf->height); 1025 1028 1026 1029 /* RA_SEL_UL is only relevant for raw modes, ignored otherwise. */ 1027 1030 switch (mf->code) { ··· 1246 1255 1247 1256 static struct v4l2_subdev_video_ops rj54n1_subdev_video_ops = { 1248 1257 .s_stream = rj54n1_s_stream, 1249 - .s_mbus_fmt = rj54n1_s_fmt, 1250 - .try_mbus_fmt = rj54n1_try_fmt, 1251 1258 .g_crop = rj54n1_g_crop, 1252 1259 .s_crop = rj54n1_s_crop, 1253 1260 .cropcap = rj54n1_cropcap, ··· 1256 1267 static const struct v4l2_subdev_pad_ops rj54n1_subdev_pad_ops = { 1257 1268 .enum_mbus_code = rj54n1_enum_mbus_code, 1258 1269 .get_fmt = rj54n1_get_fmt, 1270 + .set_fmt = rj54n1_set_fmt, 1259 1271 }; 1260 1272 1261 1273 static struct v4l2_subdev_ops rj54n1_subdev_ops = {
+11 -4
drivers/media/i2c/soc_camera/tw9910.c
··· 742 742 return ret; 743 743 } 744 744 745 - static int tw9910_try_fmt(struct v4l2_subdev *sd, 746 - struct v4l2_mbus_framefmt *mf) 745 + static int tw9910_set_fmt(struct v4l2_subdev *sd, 746 + struct v4l2_subdev_pad_config *cfg, 747 + struct v4l2_subdev_format *format) 747 748 { 749 + struct v4l2_mbus_framefmt *mf = &format->format; 748 750 struct i2c_client *client = v4l2_get_subdevdata(sd); 749 751 struct tw9910_priv *priv = to_tw9910(client); 750 752 const struct tw9910_scale_ctrl *scale; 753 + 754 + if (format->pad) 755 + return -EINVAL; 751 756 752 757 if (V4L2_FIELD_ANY == mf->field) { 753 758 mf->field = V4L2_FIELD_INTERLACED_BT; ··· 774 769 mf->width = scale->width; 775 770 mf->height = scale->height; 776 771 772 + if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE) 773 + return tw9910_s_fmt(sd, mf); 774 + cfg->try_fmt = *mf; 777 775 return 0; 778 776 } 779 777 ··· 894 886 .s_std = tw9910_s_std, 895 887 .g_std = tw9910_g_std, 896 888 .s_stream = tw9910_s_stream, 897 - .s_mbus_fmt = tw9910_s_fmt, 898 - .try_mbus_fmt = tw9910_try_fmt, 899 889 .cropcap = tw9910_cropcap, 900 890 .g_crop = tw9910_g_crop, 901 891 .g_mbus_config = tw9910_g_mbus_config, ··· 904 898 static const struct v4l2_subdev_pad_ops tw9910_subdev_pad_ops = { 905 899 .enum_mbus_code = tw9910_enum_mbus_code, 906 900 .get_fmt = tw9910_get_fmt, 901 + .set_fmt = tw9910_set_fmt, 907 902 }; 908 903 909 904 static struct v4l2_subdev_ops tw9910_subdev_ops = {
+18 -20
drivers/media/i2c/sr030pc30.c
··· 529 529 } 530 530 531 531 /* Return nearest media bus frame format. */ 532 - static int sr030pc30_try_fmt(struct v4l2_subdev *sd, 533 - struct v4l2_mbus_framefmt *mf) 532 + static int sr030pc30_set_fmt(struct v4l2_subdev *sd, 533 + struct v4l2_subdev_pad_config *cfg, 534 + struct v4l2_subdev_format *format) 534 535 { 535 - if (!sd || !mf) 536 + struct sr030pc30_info *info = sd ? to_sr030pc30(sd) : NULL; 537 + const struct sr030pc30_format *fmt; 538 + struct v4l2_mbus_framefmt *mf; 539 + 540 + if (!sd || !format) 536 541 return -EINVAL; 537 542 538 - try_fmt(sd, mf); 539 - return 0; 540 - } 541 - 542 - static int sr030pc30_s_fmt(struct v4l2_subdev *sd, 543 - struct v4l2_mbus_framefmt *mf) 544 - { 545 - struct sr030pc30_info *info = to_sr030pc30(sd); 546 - 547 - if (!sd || !mf) 543 + mf = &format->format; 544 + if (format->pad) 548 545 return -EINVAL; 549 546 550 - info->curr_fmt = try_fmt(sd, mf); 547 + fmt = try_fmt(sd, mf); 548 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 549 + cfg->try_fmt = *mf; 550 + return 0; 551 + } 552 + 553 + info->curr_fmt = fmt; 551 554 552 555 return sr030pc30_set_params(sd); 553 556 } ··· 645 642 .querymenu = v4l2_subdev_querymenu, 646 643 }; 647 644 648 - static const struct v4l2_subdev_video_ops sr030pc30_video_ops = { 649 - .s_mbus_fmt = sr030pc30_s_fmt, 650 - .try_mbus_fmt = sr030pc30_try_fmt, 651 - }; 652 - 653 645 static const struct v4l2_subdev_pad_ops sr030pc30_pad_ops = { 654 646 .enum_mbus_code = sr030pc30_enum_mbus_code, 655 647 .get_fmt = sr030pc30_get_fmt, 648 + .set_fmt = sr030pc30_set_fmt, 656 649 }; 657 650 658 651 static const struct v4l2_subdev_ops sr030pc30_ops = { 659 652 .core = &sr030pc30_core_ops, 660 - .video = &sr030pc30_video_ops, 661 653 .pad = &sr030pc30_pad_ops, 662 654 }; 663 655
+13 -15
drivers/media/i2c/vs6624.c
··· 568 568 return 0; 569 569 } 570 570 571 - static int vs6624_try_mbus_fmt(struct v4l2_subdev *sd, 572 - struct v4l2_mbus_framefmt *fmt) 571 + static int vs6624_set_fmt(struct v4l2_subdev *sd, 572 + struct v4l2_subdev_pad_config *cfg, 573 + struct v4l2_subdev_format *format) 573 574 { 575 + struct v4l2_mbus_framefmt *fmt = &format->format; 576 + struct vs6624 *sensor = to_vs6624(sd); 574 577 int index; 578 + 579 + if (format->pad) 580 + return -EINVAL; 575 581 576 582 for (index = 0; index < ARRAY_SIZE(vs6624_formats); index++) 577 583 if (vs6624_formats[index].mbus_code == fmt->code) ··· 597 591 fmt->height = fmt->height & (~3); 598 592 fmt->field = V4L2_FIELD_NONE; 599 593 fmt->colorspace = vs6624_formats[index].colorspace; 600 - return 0; 601 - } 602 594 603 - static int vs6624_s_mbus_fmt(struct v4l2_subdev *sd, 604 - struct v4l2_mbus_framefmt *fmt) 605 - { 606 - struct vs6624 *sensor = to_vs6624(sd); 607 - int ret; 608 - 609 - ret = vs6624_try_mbus_fmt(sd, fmt); 610 - if (ret) 611 - return ret; 595 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 596 + cfg->try_fmt = *fmt; 597 + return 0; 598 + } 612 599 613 600 /* set image format */ 614 601 switch (fmt->code) { ··· 742 743 }; 743 744 744 745 static const struct v4l2_subdev_video_ops vs6624_video_ops = { 745 - .try_mbus_fmt = vs6624_try_mbus_fmt, 746 - .s_mbus_fmt = vs6624_s_mbus_fmt, 747 746 .s_parm = vs6624_s_parm, 748 747 .g_parm = vs6624_g_parm, 749 748 .s_stream = vs6624_s_stream, ··· 750 753 static const struct v4l2_subdev_pad_ops vs6624_pad_ops = { 751 754 .enum_mbus_code = vs6624_enum_mbus_code, 752 755 .get_fmt = vs6624_get_fmt, 756 + .set_fmt = vs6624_set_fmt, 753 757 }; 754 758 755 759 static const struct v4l2_subdev_ops vs6624_ops = {
+17 -18
drivers/media/platform/soc_camera/sh_mobile_csi2.c
··· 45 45 46 46 static void sh_csi2_hwinit(struct sh_csi2 *priv); 47 47 48 - static int sh_csi2_try_fmt(struct v4l2_subdev *sd, 49 - struct v4l2_mbus_framefmt *mf) 48 + static int sh_csi2_set_fmt(struct v4l2_subdev *sd, 49 + struct v4l2_subdev_pad_config *cfg, 50 + struct v4l2_subdev_format *format) 50 51 { 51 52 struct sh_csi2 *priv = container_of(sd, struct sh_csi2, subdev); 52 53 struct sh_csi2_pdata *pdata = priv->pdev->dev.platform_data; 54 + struct v4l2_mbus_framefmt *mf = &format->format; 55 + u32 tmp = (priv->client->channel & 3) << 8; 56 + 57 + if (format->pad) 58 + return -EINVAL; 53 59 54 60 if (mf->width > 8188) 55 61 mf->width = 8188; ··· 91 85 break; 92 86 } 93 87 94 - return 0; 95 - } 88 + if (format->which == V4L2_SUBDEV_FORMAT_TRY) { 89 + cfg->try_fmt = *mf; 90 + return 0; 91 + } 96 92 97 - /* 98 - * We have done our best in try_fmt to try and tell the sensor, which formats 99 - * we support. If now the configuration is unsuitable for us we can only 100 - * error out. 101 - */ 102 - static int sh_csi2_s_fmt(struct v4l2_subdev *sd, 103 - struct v4l2_mbus_framefmt *mf) 104 - { 105 - struct sh_csi2 *priv = container_of(sd, struct sh_csi2, subdev); 106 - u32 tmp = (priv->client->channel & 3) << 8; 107 - 108 - dev_dbg(sd->v4l2_dev->dev, "%s(%u)\n", __func__, mf->code); 109 93 if (mf->width > 8188 || mf->width & 1) 110 94 return -EINVAL; 111 95 ··· 207 211 } 208 212 209 213 static struct v4l2_subdev_video_ops sh_csi2_subdev_video_ops = { 210 - .s_mbus_fmt = sh_csi2_s_fmt, 211 - .try_mbus_fmt = sh_csi2_try_fmt, 212 214 .g_mbus_config = sh_csi2_g_mbus_config, 213 215 .s_mbus_config = sh_csi2_s_mbus_config, 216 + }; 217 + 218 + static struct v4l2_subdev_pad_ops sh_csi2_subdev_pad_ops = { 219 + .set_fmt = sh_csi2_set_fmt, 214 220 }; 215 221 216 222 static void sh_csi2_hwinit(struct sh_csi2 *priv) ··· 311 313 static struct v4l2_subdev_ops sh_csi2_subdev_ops = { 312 314 .core = &sh_csi2_subdev_core_ops, 313 315 .video = &sh_csi2_subdev_video_ops, 316 + .pad = &sh_csi2_subdev_pad_ops, 314 317 }; 315 318 316 319 static int sh_csi2_probe(struct platform_device *pdev)