summaryrefslogtreecommitdiffstats
path: root/drivers/media/common/v4l2-tpg
diff options
context:
space:
mode:
authorRicardo Ribalda Delgado <ricardo.ribalda@gmail.com>2016-07-18 09:16:15 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-21 15:54:16 -0200
commit429175e41f01419ad81f144acabb09be904682cd (patch)
tree114777d148797428ffbdb7dca33b9c98e702e164 /drivers/media/common/v4l2-tpg
parent5f3d32ec739fcfe83bb3e39a0ca44f3b097e5a94 (diff)
downloadlinux-429175e41f01419ad81f144acabb09be904682cd.tar.gz
linux-429175e41f01419ad81f144acabb09be904682cd.tar.bz2
linux-429175e41f01419ad81f144acabb09be904682cd.zip
[media] vivid: Add support for HSV encoding
Support HSV encoding. Most of the logic is replicated from ycbcr_enc. Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/common/v4l2-tpg')
-rw-r--r--drivers/media/common/v4l2-tpg/v4l2-tpg-core.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
index ed37ae307cac..28d7b072d867 100644
--- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
+++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
@@ -504,6 +504,7 @@ static void color_to_hsv(struct tpg_data *tpg, int r, int g, int b,
int max_rgb, min_rgb, diff_rgb;
int aux;
int third;
+ int third_size;
r >>= 4;
g >>= 4;
@@ -530,30 +531,36 @@ static void color_to_hsv(struct tpg_data *tpg, int r, int g, int b,
return;
}
+ third_size = (tpg->real_hsv_enc == V4L2_HSV_ENC_180) ? 60 : 85;
+
/* Hue */
if (max_rgb == r) {
aux = g - b;
third = 0;
} else if (max_rgb == g) {
aux = b - r;
- third = 60;
+ third = third_size;
} else {
aux = r - g;
- third = 120;
+ third = third_size * 2;
}
- aux *= 30;
+ aux *= third_size / 2;
aux += diff_rgb / 2;
aux /= diff_rgb;
aux += third;
/* Clamp Hue */
- if (aux < 0)
- aux += 180;
- else if (aux > 180)
- aux -= 180;
- *h = aux;
+ if (tpg->real_hsv_enc == V4L2_HSV_ENC_180) {
+ if (aux < 0)
+ aux += 180;
+ else if (aux > 180)
+ aux -= 180;
+ } else {
+ aux = aux & 0xff;
+ }
+ *h = aux;
}
static void rgb2ycbcr(const int m[3][3], int r, int g, int b,
@@ -1928,6 +1935,7 @@ static void tpg_recalc(struct tpg_data *tpg)
tpg->recalc_lines = true;
tpg->real_xfer_func = tpg->xfer_func;
tpg->real_ycbcr_enc = tpg->ycbcr_enc;
+ tpg->real_hsv_enc = tpg->hsv_enc;
tpg->real_quantization = tpg->quantization;
if (tpg->xfer_func == V4L2_XFER_FUNC_DEFAULT)
@@ -2018,6 +2026,7 @@ void tpg_log_status(struct tpg_data *tpg)
pr_info("tpg colorspace: %d\n", tpg->colorspace);
pr_info("tpg transfer function: %d/%d\n", tpg->xfer_func, tpg->real_xfer_func);
pr_info("tpg Y'CbCr encoding: %d/%d\n", tpg->ycbcr_enc, tpg->real_ycbcr_enc);
+ pr_info("tpg HSV encoding: %d/%d\n", tpg->hsv_enc, tpg->real_hsv_enc);
pr_info("tpg quantization: %d/%d\n", tpg->quantization, tpg->real_quantization);
pr_info("tpg RGB range: %d/%d\n", tpg->rgb_range, tpg->real_rgb_range);
}