diff options
author | Jacek Anaszewski <j.anaszewski@samsung.com> | 2014-07-11 11:19:48 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-30 18:21:07 -0400 |
commit | 39c344c4487a23c1399c384b78399b5947a47b50 (patch) | |
tree | 5725dd1c6b5f5ba9a65eddba8f07b6de2121682d /drivers/media | |
parent | 5a71671af3727502386ac9b5497d6436286ed8a9 (diff) |
[media] s5p-jpeg: add chroma subsampling adjustment for Exynos3250
Take into account limitations specific to the Exynos3250 SoC,
regarding setting the chroma subsampling control's value.
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/s5p-jpeg/jpeg-core.c | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index eb13fdfb15a3..e66acbc2a82d 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c | |||
@@ -1603,36 +1603,53 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl) | |||
1603 | return 0; | 1603 | return 0; |
1604 | } | 1604 | } |
1605 | 1605 | ||
1606 | static int s5p_jpeg_try_ctrl(struct v4l2_ctrl *ctrl) | 1606 | static int s5p_jpeg_adjust_subs_ctrl(struct s5p_jpeg_ctx *ctx, int *ctrl_val) |
1607 | { | 1607 | { |
1608 | struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl); | 1608 | switch (ctx->jpeg->variant->version) { |
1609 | unsigned long flags; | 1609 | case SJPEG_S5P: |
1610 | int ret = 0; | 1610 | return 0; |
1611 | 1611 | case SJPEG_EXYNOS3250: | |
1612 | spin_lock_irqsave(&ctx->jpeg->slock, flags); | 1612 | /* |
1613 | 1613 | * The exynos3250 device can produce JPEG image only | |
1614 | if (ctrl->id == V4L2_CID_JPEG_CHROMA_SUBSAMPLING) { | 1614 | * of 4:4:4 subsampling when given RGB32 source image. |
1615 | if (ctx->jpeg->variant->version == SJPEG_S5P) | 1615 | */ |
1616 | goto error_free; | 1616 | if (ctx->out_q.fmt->fourcc == V4L2_PIX_FMT_RGB32) |
1617 | *ctrl_val = 0; | ||
1618 | break; | ||
1619 | case SJPEG_EXYNOS4: | ||
1617 | /* | 1620 | /* |
1618 | * The exynos4x12 device requires input raw image fourcc | 1621 | * The exynos4x12 device requires input raw image fourcc |
1619 | * to be V4L2_PIX_FMT_GREY if gray jpeg format | 1622 | * to be V4L2_PIX_FMT_GREY if gray jpeg format |
1620 | * is to be set. | 1623 | * is to be set. |
1621 | */ | 1624 | */ |
1622 | if (ctx->out_q.fmt->fourcc != V4L2_PIX_FMT_GREY && | 1625 | if (ctx->out_q.fmt->fourcc != V4L2_PIX_FMT_GREY && |
1623 | ctrl->val == V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY) { | 1626 | *ctrl_val == V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY) |
1624 | ret = -EINVAL; | 1627 | return -EINVAL; |
1625 | goto error_free; | 1628 | break; |
1626 | } | ||
1627 | /* | ||
1628 | * The exynos4x12 device requires resulting jpeg subsampling | ||
1629 | * not to be lower than the input raw image subsampling. | ||
1630 | */ | ||
1631 | if (ctx->out_q.fmt->subsampling > ctrl->val) | ||
1632 | ctrl->val = ctx->out_q.fmt->subsampling; | ||
1633 | } | 1629 | } |
1634 | 1630 | ||
1635 | error_free: | 1631 | /* |
1632 | * The exynos4x12 and exynos3250 devices require resulting | ||
1633 | * jpeg subsampling not to be lower than the input raw image | ||
1634 | * subsampling. | ||
1635 | */ | ||
1636 | if (ctx->out_q.fmt->subsampling > *ctrl_val) | ||
1637 | *ctrl_val = ctx->out_q.fmt->subsampling; | ||
1638 | |||
1639 | return 0; | ||
1640 | } | ||
1641 | |||
1642 | static int s5p_jpeg_try_ctrl(struct v4l2_ctrl *ctrl) | ||
1643 | { | ||
1644 | struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl); | ||
1645 | unsigned long flags; | ||
1646 | int ret = 0; | ||
1647 | |||
1648 | spin_lock_irqsave(&ctx->jpeg->slock, flags); | ||
1649 | |||
1650 | if (ctrl->id == V4L2_CID_JPEG_CHROMA_SUBSAMPLING) | ||
1651 | ret = s5p_jpeg_adjust_subs_ctrl(ctx, &ctrl->val); | ||
1652 | |||
1636 | spin_unlock_irqrestore(&ctx->jpeg->slock, flags); | 1653 | spin_unlock_irqrestore(&ctx->jpeg->slock, flags); |
1637 | return ret; | 1654 | return ret; |
1638 | } | 1655 | } |