From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
To: Jonathan Corbet <corbet@lwn.net>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Hans Verkuil <hverkuil@xs4all.nl>,
Markus Heiser <markus.heiser@darmarIT.de>,
Helen Mae Koike Fornazier <helen.koike@collabora.co.uk>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Antti Palosaari <crope@iki.fi>,
Philipp Zabel <p.zabel@pengutronix.de>,
Shuah Khan <shuahkh@osg.samsung.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Subject: [PATCH v3 7/9] [media] vivid: Introduce TPG_COLOR_ENC_LUMA
Date: Sat, 16 Jul 2016 12:41:54 +0200 [thread overview]
Message-ID: <1468665716-10178-8-git-send-email-ricardo.ribalda@gmail.com> (raw)
In-Reply-To: <1468665716-10178-1-git-send-email-ricardo.ribalda@gmail.com>
Simplifies handling of Gray formats.
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 26 +++++++++++++++++++------
drivers/media/platform/vivid/vivid-vid-common.c | 6 +++---
include/media/v4l2-tpg.h | 1 +
3 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index ba3fe65ceb98..e91bf3cbaab9 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -234,10 +234,12 @@ bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc)
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_ARGB32:
case V4L2_PIX_FMT_ABGR32:
+ tpg->color_enc = TGP_COLOR_ENC_RGB;
+ break;
case V4L2_PIX_FMT_GREY:
case V4L2_PIX_FMT_Y16:
case V4L2_PIX_FMT_Y16_BE:
- tpg->color_enc = TGP_COLOR_ENC_RGB;
+ tpg->color_enc = TGP_COLOR_ENC_LUMA;
break;
case V4L2_PIX_FMT_YUV444:
case V4L2_PIX_FMT_YUV555:
@@ -825,9 +827,9 @@ static void precalculate_color(struct tpg_data *tpg, int k)
g <<= 4;
b <<= 4;
}
- if (tpg->qual == TPG_QUAL_GRAY || tpg->fourcc == V4L2_PIX_FMT_GREY ||
- tpg->fourcc == V4L2_PIX_FMT_Y16 ||
- tpg->fourcc == V4L2_PIX_FMT_Y16_BE) {
+
+ if (tpg->qual == TPG_QUAL_GRAY ||
+ tpg->color_enc == TGP_COLOR_ENC_LUMA) {
/* Rec. 709 Luma function */
/* (0.2126, 0.7152, 0.0722) * (255 * 256) */
r = g = b = (13879 * r + 46688 * g + 4713 * b) >> 16;
@@ -867,8 +869,9 @@ static void precalculate_color(struct tpg_data *tpg, int k)
b = (b - (16 << 4)) * 255 / 219;
}
- if (tpg->brightness != 128 || tpg->contrast != 128 ||
- tpg->saturation != 128 || tpg->hue) {
+ if ((tpg->brightness != 128 || tpg->contrast != 128 ||
+ tpg->saturation != 128 || tpg->hue) &&
+ tpg->color_enc != TGP_COLOR_ENC_LUMA) {
/* Implement these operations */
int y, cb, cr;
int tmp_cb, tmp_cr;
@@ -894,6 +897,10 @@ static void precalculate_color(struct tpg_data *tpg, int k)
return;
}
ycbcr_to_color(tpg, y, cb, cr, &r, &g, &b);
+ } else if ((tpg->brightness != 128 || tpg->contrast != 128) &&
+ tpg->color_enc == TGP_COLOR_ENC_LUMA) {
+ r = (16 << 4) + ((r - (16 << 4)) * tpg->contrast) / 128;
+ r += (tpg->brightness << 4) - (128 << 4);
}
switch (tpg->color_enc) {
@@ -944,6 +951,11 @@ static void precalculate_color(struct tpg_data *tpg, int k)
tpg->colors[k][2] = cr;
break;
}
+ case TGP_COLOR_ENC_LUMA:
+ {
+ tpg->colors[k][0] = r >> 4;
+ break;
+ }
case TGP_COLOR_ENC_RGB:
{
if (tpg->real_quantization == V4L2_QUANTIZATION_LIM_RANGE) {
@@ -1985,6 +1997,8 @@ static const char *tpg_color_enc_str(enum tgp_color_enc
return "HSV";
case TGP_COLOR_ENC_YUV:
return "YCbCr";
+ case TGP_COLOR_ENC_LUMA:
+ return "Luma";
case TGP_COLOR_ENC_RGB:
default:
return "RGB";
diff --git a/drivers/media/platform/vivid/vivid-vid-common.c b/drivers/media/platform/vivid/vivid-vid-common.c
index 869e26ea7cf5..b78bca4c2f16 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -184,7 +184,7 @@ struct vivid_fmt vivid_formats[] = {
.fourcc = V4L2_PIX_FMT_GREY,
.vdownsampling = { 1 },
.bit_depth = { 8 },
- .color_enc = TGP_COLOR_ENC_YUV,
+ .color_enc = TGP_COLOR_ENC_LUMA,
.planes = 1,
.buffers = 1,
},
@@ -192,7 +192,7 @@ struct vivid_fmt vivid_formats[] = {
.fourcc = V4L2_PIX_FMT_Y16,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .color_enc = TGP_COLOR_ENC_YUV,
+ .color_enc = TGP_COLOR_ENC_LUMA,
.planes = 1,
.buffers = 1,
},
@@ -200,7 +200,7 @@ struct vivid_fmt vivid_formats[] = {
.fourcc = V4L2_PIX_FMT_Y16_BE,
.vdownsampling = { 1 },
.bit_depth = { 16 },
- .color_enc = TGP_COLOR_ENC_YUV,
+ .color_enc = TGP_COLOR_ENC_LUMA,
.planes = 1,
.buffers = 1,
},
diff --git a/include/media/v4l2-tpg.h b/include/media/v4l2-tpg.h
index 0f632ec619aa..d2487c12657d 100644
--- a/include/media/v4l2-tpg.h
+++ b/include/media/v4l2-tpg.h
@@ -91,6 +91,7 @@ enum tgp_color_enc {
TGP_COLOR_ENC_RGB,
TGP_COLOR_ENC_YUV,
TGP_COLOR_ENC_HSV,
+ TGP_COLOR_ENC_LUMA,
};
extern const char * const tpg_aspect_strings[];
--
2.8.1
next prev parent reply other threads:[~2016-07-16 10:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-16 10:41 [PATCH v3 0/9] Add HSV format Ricardo Ribalda Delgado
2016-07-16 10:41 ` [PATCH v3 1/9] [media] videodev2.h Add HSV formats Ricardo Ribalda Delgado
2016-07-16 10:41 ` [PATCH v3 2/9] [media] Documentation: Add HSV format Ricardo Ribalda Delgado
2016-07-16 10:41 ` [PATCH v3 3/9] [media] Documentation: Add Ricardo Ribalda Ricardo Ribalda Delgado
2016-07-16 10:41 ` [PATCH v3 4/9] [media] vivid: code refactor for color encoding Ricardo Ribalda Delgado
2016-07-18 8:40 ` Hans Verkuil
2016-07-16 10:41 ` [PATCH v3 5/9] [media] vivid: Add support for HSV formats Ricardo Ribalda Delgado
2016-07-16 10:41 ` [PATCH v3 6/9] [media] vivid: Rename variable Ricardo Ribalda Delgado
2016-07-16 10:41 ` Ricardo Ribalda Delgado [this message]
2016-07-16 10:41 ` [PATCH v3 8/9] [media] vivid: Fix YUV555 and YUV565 handling Ricardo Ribalda Delgado
2016-07-18 8:51 ` Hans Verkuil
2016-07-18 9:03 ` Ricardo Ribalda Delgado
2016-07-16 10:41 ` [PATCH v3 9/9] [media] vivid: Local optimization Ricardo Ribalda Delgado
2016-07-16 10:52 ` Ricardo Ribalda Delgado
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468665716-10178-8-git-send-email-ricardo.ribalda@gmail.com \
--to=ricardo.ribalda@gmail.com \
--cc=corbet@lwn.net \
--cc=crope@iki.fi \
--cc=helen.koike@collabora.co.uk \
--cc=hverkuil@xs4all.nl \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=markus.heiser@darmarIT.de \
--cc=mchehab@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=shuahkh@osg.samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®