Commit 7a785081 authored by Kaaira Gupta's avatar Kaaira Gupta Committed by Mauro Carvalho Chehab

media: tpg: Add function to return colors' order of test image

Currently there is no method to know the correct order of the colors for
a test image generated by tpg. Write a function that returns a string of
colors' order given a tpg. It returns a NULL pointer in case of test
patterns which do not have a well defined colors' order. Hence add a
NULL check for text in tpg_gen_text().

[hverkuil: white -> White (for consistency)]
Signed-off-by: default avatarKaaira Gupta <kgupta@es.iitr.ac.in>
Reviewed-by: default avatarKieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: default avatarHelen Koike <helen.koike@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9dc75e79
...@@ -1959,12 +1959,14 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], ...@@ -1959,12 +1959,14 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],
unsigned step = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1; unsigned step = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1;
unsigned div = step; unsigned div = step;
unsigned first = 0; unsigned first = 0;
unsigned len = strlen(text); unsigned len;
unsigned p; unsigned p;
if (font8x16 == NULL || basep == NULL) if (font8x16 == NULL || basep == NULL || text == NULL)
return; return;
len = strlen(text);
/* Checks if it is possible to show string */ /* Checks if it is possible to show string */
if (y + 16 >= tpg->compose.height || x + 8 >= tpg->compose.width) if (y + 16 >= tpg->compose.height || x + 8 >= tpg->compose.width)
return; return;
...@@ -2006,6 +2008,30 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], ...@@ -2006,6 +2008,30 @@ void tpg_gen_text(const struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2],
} }
EXPORT_SYMBOL_GPL(tpg_gen_text); EXPORT_SYMBOL_GPL(tpg_gen_text);
const char *tpg_g_color_order(const struct tpg_data *tpg)
{
switch (tpg->pattern) {
case TPG_PAT_75_COLORBAR:
case TPG_PAT_100_COLORBAR:
case TPG_PAT_CSC_COLORBAR:
case TPG_PAT_100_HCOLORBAR:
return "White, yellow, cyan, green, magenta, red, blue, black";
case TPG_PAT_BLACK:
return "Black";
case TPG_PAT_WHITE:
return "White";
case TPG_PAT_RED:
return "Red";
case TPG_PAT_GREEN:
return "Green";
case TPG_PAT_BLUE:
return "Blue";
default:
return NULL;
}
}
EXPORT_SYMBOL_GPL(tpg_g_color_order);
void tpg_update_mv_step(struct tpg_data *tpg) void tpg_update_mv_step(struct tpg_data *tpg)
{ {
int factor = tpg->mv_hor_mode > TPG_MOVE_NONE ? -1 : 1; int factor = tpg->mv_hor_mode > TPG_MOVE_NONE ? -1 : 1;
......
...@@ -252,6 +252,7 @@ void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std, ...@@ -252,6 +252,7 @@ void tpg_fillbuffer(struct tpg_data *tpg, v4l2_std_id std,
bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc); bool tpg_s_fourcc(struct tpg_data *tpg, u32 fourcc);
void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop, void tpg_s_crop_compose(struct tpg_data *tpg, const struct v4l2_rect *crop,
const struct v4l2_rect *compose); const struct v4l2_rect *compose);
const char *tpg_g_color_order(const struct tpg_data *tpg);
static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern) static inline void tpg_s_pattern(struct tpg_data *tpg, enum tpg_pattern pattern)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment