diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-07-28 08:49:37 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-11-03 16:27:32 -0400 |
commit | 2ad90b71231a68e2041680e3ae3b7661ebe825ec (patch) | |
tree | 06adaf857553ab6735a9a62a1064edf9f58d55da | |
parent | 022e52cfe846469363e168b6a0095e7873279811 (diff) |
[media] V4L: tw9910: remove a not really implemented cropping support
Cropping is not really correctly implemented by this driver and only
needlessly obfuscates the code. Remove it.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/tw9910.c | 129 |
1 files changed, 46 insertions, 83 deletions
diff --git a/drivers/media/video/tw9910.c b/drivers/media/video/tw9910.c index 742482e30011..686512eefed8 100644 --- a/drivers/media/video/tw9910.c +++ b/drivers/media/video/tw9910.c | |||
@@ -203,6 +203,10 @@ | |||
203 | #define RTSEL_FIELD 0x06 /* 0110 = FIELD */ | 203 | #define RTSEL_FIELD 0x06 /* 0110 = FIELD */ |
204 | #define RTSEL_RTCO 0x07 /* 0111 = RTCO ( Real Time Control ) */ | 204 | #define RTSEL_RTCO 0x07 /* 0111 = RTCO ( Real Time Control ) */ |
205 | 205 | ||
206 | /* HSYNC start and end are constant for now */ | ||
207 | #define HSYNC_START 0x0260 | ||
208 | #define HSYNC_END 0x0300 | ||
209 | |||
206 | /* | 210 | /* |
207 | * structure | 211 | * structure |
208 | */ | 212 | */ |
@@ -220,18 +224,6 @@ struct tw9910_scale_ctrl { | |||
220 | u16 vscale; | 224 | u16 vscale; |
221 | }; | 225 | }; |
222 | 226 | ||
223 | struct tw9910_cropping_ctrl { | ||
224 | u16 vdelay; | ||
225 | u16 vactive; | ||
226 | u16 hdelay; | ||
227 | u16 hactive; | ||
228 | }; | ||
229 | |||
230 | struct tw9910_hsync_ctrl { | ||
231 | u16 start; | ||
232 | u16 end; | ||
233 | }; | ||
234 | |||
235 | struct tw9910_priv { | 227 | struct tw9910_priv { |
236 | struct v4l2_subdev subdev; | 228 | struct v4l2_subdev subdev; |
237 | struct tw9910_video_info *info; | 229 | struct tw9910_video_info *info; |
@@ -329,11 +321,6 @@ static const struct tw9910_scale_ctrl tw9910_pal_scales[] = { | |||
329 | }, | 321 | }, |
330 | }; | 322 | }; |
331 | 323 | ||
332 | static const struct tw9910_hsync_ctrl tw9910_hsync_ctrl = { | ||
333 | .start = 0x0260, | ||
334 | .end = 0x0300, | ||
335 | }; | ||
336 | |||
337 | /* | 324 | /* |
338 | * general function | 325 | * general function |
339 | */ | 326 | */ |
@@ -378,21 +365,20 @@ static int tw9910_set_scale(struct i2c_client *client, | |||
378 | return ret; | 365 | return ret; |
379 | } | 366 | } |
380 | 367 | ||
381 | static int tw9910_set_hsync(struct i2c_client *client, | 368 | static int tw9910_set_hsync(struct i2c_client *client) |
382 | const struct tw9910_hsync_ctrl *hsync) | ||
383 | { | 369 | { |
384 | struct tw9910_priv *priv = to_tw9910(client); | 370 | struct tw9910_priv *priv = to_tw9910(client); |
385 | int ret; | 371 | int ret; |
386 | 372 | ||
387 | /* bit 10 - 3 */ | 373 | /* bit 10 - 3 */ |
388 | ret = i2c_smbus_write_byte_data(client, HSBEGIN, | 374 | ret = i2c_smbus_write_byte_data(client, HSBEGIN, |
389 | (hsync->start & 0x07F8) >> 3); | 375 | (HSYNC_START & 0x07F8) >> 3); |
390 | if (ret < 0) | 376 | if (ret < 0) |
391 | return ret; | 377 | return ret; |
392 | 378 | ||
393 | /* bit 10 - 3 */ | 379 | /* bit 10 - 3 */ |
394 | ret = i2c_smbus_write_byte_data(client, HSEND, | 380 | ret = i2c_smbus_write_byte_data(client, HSEND, |
395 | (hsync->end & 0x07F8) >> 3); | 381 | (HSYNC_END & 0x07F8) >> 3); |
396 | if (ret < 0) | 382 | if (ret < 0) |
397 | return ret; | 383 | return ret; |
398 | 384 | ||
@@ -400,8 +386,8 @@ static int tw9910_set_hsync(struct i2c_client *client, | |||
400 | /* bit 2 - 0 */ | 386 | /* bit 2 - 0 */ |
401 | if (1 == priv->revision) | 387 | if (1 == priv->revision) |
402 | ret = tw9910_mask_set(client, HSLOWCTL, 0x77, | 388 | ret = tw9910_mask_set(client, HSLOWCTL, 0x77, |
403 | (hsync->start & 0x0007) << 4 | | 389 | (HSYNC_START & 0x0007) << 4 | |
404 | (hsync->end & 0x0007)); | 390 | (HSYNC_END & 0x0007)); |
405 | 391 | ||
406 | return ret; | 392 | return ret; |
407 | } | 393 | } |
@@ -433,8 +419,8 @@ static int tw9910_power(struct i2c_client *client, int enable) | |||
433 | return tw9910_mask_set(client, ACNTL2, ACNTL2_PDN_MASK, acntl2); | 419 | return tw9910_mask_set(client, ACNTL2, ACNTL2_PDN_MASK, acntl2); |
434 | } | 420 | } |
435 | 421 | ||
436 | static const struct tw9910_scale_ctrl* | 422 | static const struct tw9910_scale_ctrl *tw9910_select_norm(struct soc_camera_device *icd, |
437 | tw9910_select_norm(struct soc_camera_device *icd, u32 width, u32 height) | 423 | u32 width, u32 height) |
438 | { | 424 | { |
439 | const struct tw9910_scale_ctrl *scale; | 425 | const struct tw9910_scale_ctrl *scale; |
440 | const struct tw9910_scale_ctrl *ret = NULL; | 426 | const struct tw9910_scale_ctrl *ret = NULL; |
@@ -510,10 +496,13 @@ static int tw9910_s_stream(struct v4l2_subdev *sd, int enable) | |||
510 | static int tw9910_set_bus_param(struct soc_camera_device *icd, | 496 | static int tw9910_set_bus_param(struct soc_camera_device *icd, |
511 | unsigned long flags) | 497 | unsigned long flags) |
512 | { | 498 | { |
499 | struct soc_camera_link *icl = to_soc_camera_link(icd); | ||
513 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); | 500 | struct v4l2_subdev *sd = soc_camera_to_subdev(icd); |
514 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 501 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
515 | u8 val = VSSL_VVALID | HSSL_DVALID; | 502 | u8 val = VSSL_VVALID | HSSL_DVALID; |
516 | 503 | ||
504 | flags = soc_camera_apply_sensor_flags(icl, flags); | ||
505 | |||
517 | /* | 506 | /* |
518 | * set OUTCTR1 | 507 | * set OUTCTR1 |
519 | * | 508 | * |
@@ -600,19 +589,18 @@ static int tw9910_s_register(struct v4l2_subdev *sd, | |||
600 | } | 589 | } |
601 | #endif | 590 | #endif |
602 | 591 | ||
603 | static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | 592 | static int tw9910_set_frame(struct v4l2_subdev *sd, u32 *width, u32 *height) |
604 | { | 593 | { |
605 | struct v4l2_rect *rect = &a->c; | ||
606 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 594 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
607 | struct tw9910_priv *priv = to_tw9910(client); | 595 | struct tw9910_priv *priv = to_tw9910(client); |
608 | struct soc_camera_device *icd = client->dev.platform_data; | 596 | struct soc_camera_device *icd = client->dev.platform_data; |
609 | int ret = -EINVAL; | 597 | int ret = -EINVAL; |
610 | u8 val; | 598 | u8 val; |
611 | 599 | ||
612 | /* | 600 | /* |
613 | * select suitable norm | 601 | * select suitable norm |
614 | */ | 602 | */ |
615 | priv->scale = tw9910_select_norm(icd, rect->width, rect->height); | 603 | priv->scale = tw9910_select_norm(icd, *width, *height); |
616 | if (!priv->scale) | 604 | if (!priv->scale) |
617 | goto tw9910_set_fmt_error; | 605 | goto tw9910_set_fmt_error; |
618 | 606 | ||
@@ -670,14 +658,12 @@ static int tw9910_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | |||
670 | /* | 658 | /* |
671 | * set hsync | 659 | * set hsync |
672 | */ | 660 | */ |
673 | ret = tw9910_set_hsync(client, &tw9910_hsync_ctrl); | 661 | ret = tw9910_set_hsync(client); |
674 | if (ret < 0) | 662 | if (ret < 0) |
675 | goto tw9910_set_fmt_error; | 663 | goto tw9910_set_fmt_error; |
676 | 664 | ||
677 | rect->width = priv->scale->width; | 665 | *width = priv->scale->width; |
678 | rect->height = priv->scale->height; | 666 | *height = priv->scale->height; |
679 | rect->left = 0; | ||
680 | rect->top = 0; | ||
681 | 667 | ||
682 | return ret; | 668 | return ret; |
683 | 669 | ||
@@ -692,27 +678,17 @@ tw9910_set_fmt_error: | |||
692 | static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | 678 | static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) |
693 | { | 679 | { |
694 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 680 | struct i2c_client *client = v4l2_get_subdevdata(sd); |
695 | struct tw9910_priv *priv = to_tw9910(client); | 681 | struct soc_camera_device *icd = client->dev.platform_data; |
696 | |||
697 | if (!priv->scale) { | ||
698 | int ret; | ||
699 | struct v4l2_crop crop = { | ||
700 | .c = { | ||
701 | .left = 0, | ||
702 | .top = 0, | ||
703 | .width = 640, | ||
704 | .height = 480, | ||
705 | }, | ||
706 | }; | ||
707 | ret = tw9910_s_crop(sd, &crop); | ||
708 | if (ret < 0) | ||
709 | return ret; | ||
710 | } | ||
711 | 682 | ||
712 | a->c.left = 0; | 683 | a->c.left = 0; |
713 | a->c.top = 0; | 684 | a->c.top = 0; |
714 | a->c.width = priv->scale->width; | 685 | if (icd->vdev->current_norm & V4L2_STD_NTSC) { |
715 | a->c.height = priv->scale->height; | 686 | a->c.width = 640; |
687 | a->c.height = 480; | ||
688 | } else { | ||
689 | a->c.width = 768; | ||
690 | a->c.height = 576; | ||
691 | } | ||
716 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 692 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
717 | 693 | ||
718 | return 0; | 694 | return 0; |
@@ -720,14 +696,19 @@ static int tw9910_g_crop(struct v4l2_subdev *sd, struct v4l2_crop *a) | |||
720 | 696 | ||
721 | static int tw9910_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) | 697 | static int tw9910_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a) |
722 | { | 698 | { |
699 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
700 | struct soc_camera_device *icd = client->dev.platform_data; | ||
701 | |||
723 | a->bounds.left = 0; | 702 | a->bounds.left = 0; |
724 | a->bounds.top = 0; | 703 | a->bounds.top = 0; |
725 | a->bounds.width = 768; | 704 | if (icd->vdev->current_norm & V4L2_STD_NTSC) { |
726 | a->bounds.height = 576; | 705 | a->bounds.width = 640; |
727 | a->defrect.left = 0; | 706 | a->bounds.height = 480; |
728 | a->defrect.top = 0; | 707 | } else { |
729 | a->defrect.width = 640; | 708 | a->bounds.width = 768; |
730 | a->defrect.height = 480; | 709 | a->bounds.height = 576; |
710 | } | ||
711 | a->defrect = a->bounds; | ||
731 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 712 | a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
732 | a->pixelaspect.numerator = 1; | 713 | a->pixelaspect.numerator = 1; |
733 | a->pixelaspect.denominator = 1; | 714 | a->pixelaspect.denominator = 1; |
@@ -743,15 +724,8 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd, | |||
743 | 724 | ||
744 | if (!priv->scale) { | 725 | if (!priv->scale) { |
745 | int ret; | 726 | int ret; |
746 | struct v4l2_crop crop = { | 727 | u32 width = 640, height = 480; |
747 | .c = { | 728 | ret = tw9910_set_frame(sd, &width, &height); |
748 | .left = 0, | ||
749 | .top = 0, | ||
750 | .width = 640, | ||
751 | .height = 480, | ||
752 | }, | ||
753 | }; | ||
754 | ret = tw9910_s_crop(sd, &crop); | ||
755 | if (ret < 0) | 729 | if (ret < 0) |
756 | return ret; | 730 | return ret; |
757 | } | 731 | } |
@@ -768,17 +742,7 @@ static int tw9910_g_fmt(struct v4l2_subdev *sd, | |||
768 | static int tw9910_s_fmt(struct v4l2_subdev *sd, | 742 | static int tw9910_s_fmt(struct v4l2_subdev *sd, |
769 | struct v4l2_mbus_framefmt *mf) | 743 | struct v4l2_mbus_framefmt *mf) |
770 | { | 744 | { |
771 | struct i2c_client *client = v4l2_get_subdevdata(sd); | 745 | u32 width = mf->width, height = mf->height; |
772 | struct tw9910_priv *priv = to_tw9910(client); | ||
773 | /* See tw9910_s_crop() - no proper cropping support */ | ||
774 | struct v4l2_crop a = { | ||
775 | .c = { | ||
776 | .left = 0, | ||
777 | .top = 0, | ||
778 | .width = mf->width, | ||
779 | .height = mf->height, | ||
780 | }, | ||
781 | }; | ||
782 | int ret; | 746 | int ret; |
783 | 747 | ||
784 | WARN_ON(mf->field != V4L2_FIELD_ANY && | 748 | WARN_ON(mf->field != V4L2_FIELD_ANY && |
@@ -792,10 +756,10 @@ static int tw9910_s_fmt(struct v4l2_subdev *sd, | |||
792 | 756 | ||
793 | mf->colorspace = V4L2_COLORSPACE_JPEG; | 757 | mf->colorspace = V4L2_COLORSPACE_JPEG; |
794 | 758 | ||
795 | ret = tw9910_s_crop(sd, &a); | 759 | ret = tw9910_set_frame(sd, &width, &height); |
796 | if (!ret) { | 760 | if (!ret) { |
797 | mf->width = priv->scale->width; | 761 | mf->width = width; |
798 | mf->height = priv->scale->height; | 762 | mf->height = height; |
799 | } | 763 | } |
800 | return ret; | 764 | return ret; |
801 | } | 765 | } |
@@ -905,7 +869,6 @@ static struct v4l2_subdev_video_ops tw9910_subdev_video_ops = { | |||
905 | .try_mbus_fmt = tw9910_try_fmt, | 869 | .try_mbus_fmt = tw9910_try_fmt, |
906 | .cropcap = tw9910_cropcap, | 870 | .cropcap = tw9910_cropcap, |
907 | .g_crop = tw9910_g_crop, | 871 | .g_crop = tw9910_g_crop, |
908 | .s_crop = tw9910_s_crop, | ||
909 | .enum_mbus_fmt = tw9910_enum_fmt, | 872 | .enum_mbus_fmt = tw9910_enum_fmt, |
910 | }; | 873 | }; |
911 | 874 | ||