Commit 5e729393 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] vivid-tpg: move common parameters to tpg_draw_params

Replace local variables by fields in the tpg_draw_params struct.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent e76036d8
...@@ -1545,23 +1545,21 @@ struct tpg_draw_params { ...@@ -1545,23 +1545,21 @@ struct tpg_draw_params {
void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf) void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 *vbuf)
{ {
bool is_tv = std; struct tpg_draw_params params;
bool is_60hz = is_tv && (std & V4L2_STD_525_60);
unsigned mv_hor_old = tpg->mv_hor_count % tpg->src_width; unsigned mv_hor_old = tpg->mv_hor_count % tpg->src_width;
unsigned mv_hor_new = (tpg->mv_hor_count + tpg->mv_hor_step) % tpg->src_width; unsigned mv_hor_new = (tpg->mv_hor_count + tpg->mv_hor_step) % tpg->src_width;
unsigned mv_vert_old = tpg->mv_vert_count % tpg->src_height; unsigned mv_vert_old = tpg->mv_vert_count % tpg->src_height;
unsigned mv_vert_new = (tpg->mv_vert_count + tpg->mv_vert_step) % tpg->src_height; unsigned mv_vert_new = (tpg->mv_vert_count + tpg->mv_vert_step) % tpg->src_height;
unsigned wss_width; unsigned wss_width;
unsigned f; unsigned f;
int hmax = (tpg->compose.height * tpg->perc_fill) / 100;
int h; int h;
unsigned twopixsize = tpg->twopixelsize[p]; unsigned twopixsize;
unsigned vdiv = tpg->vdownsampling[p]; unsigned vdiv = tpg->vdownsampling[p];
unsigned img_width = tpg_hdiv(tpg, p, tpg->compose.width); unsigned img_width;
unsigned line_offset; unsigned line_offset;
unsigned left_pillar_width = 0; unsigned left_pillar_width = 0;
unsigned right_pillar_start = img_width; unsigned right_pillar_start;
unsigned stride = tpg->bytesperline[p]; unsigned stride;
unsigned factor = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1; unsigned factor = V4L2_FIELD_HAS_T_OR_B(tpg->field) ? 2 : 1;
u8 *orig_vbuf = vbuf; u8 *orig_vbuf = vbuf;
...@@ -1573,6 +1571,17 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 ...@@ -1573,6 +1571,17 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8
tpg_recalc(tpg); tpg_recalc(tpg);
params.is_tv = std;
params.is_60hz = std & V4L2_STD_525_60;
params.twopixsize = tpg->twopixelsize[p];
params.img_width = tpg_hdiv(tpg, p, tpg->compose.width);
params.stride = tpg->bytesperline[p];
params.hmax = (tpg->compose.height * tpg->perc_fill) / 100;
twopixsize = params.twopixsize;
img_width = params.img_width;
stride = params.stride;
mv_hor_old = tpg_hscale_div(tpg, p, mv_hor_old); mv_hor_old = tpg_hscale_div(tpg, p, mv_hor_old);
mv_hor_new = tpg_hscale_div(tpg, p, mv_hor_new); mv_hor_new = tpg_hscale_div(tpg, p, mv_hor_new);
wss_width = tpg->crop.left < tpg->src_width / 2 ? wss_width = tpg->crop.left < tpg->src_width / 2 ?
...@@ -1589,6 +1598,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 ...@@ -1589,6 +1598,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8
left_pillar_width = tpg->crop.width; left_pillar_width = tpg->crop.width;
left_pillar_width = tpg_hscale_div(tpg, p, left_pillar_width); left_pillar_width = tpg_hscale_div(tpg, p, left_pillar_width);
} }
right_pillar_start = img_width;
if (tpg->crop.left + tpg->crop.width > tpg->border.left + tpg->border.width) { if (tpg->crop.left + tpg->crop.width > tpg->border.left + tpg->border.width) {
right_pillar_start = tpg->border.left + tpg->border.width - tpg->crop.left; right_pillar_start = tpg->border.left + tpg->border.width - tpg->crop.left;
right_pillar_start = tpg_hscale_div(tpg, p, right_pillar_start); right_pillar_start = tpg_hscale_div(tpg, p, right_pillar_start);
...@@ -1596,7 +1606,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 ...@@ -1596,7 +1606,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8
right_pillar_start = img_width; right_pillar_start = img_width;
} }
f = tpg->field == (is_60hz ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM); f = tpg->field == (params.is_60hz ? V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
for (h = 0; h < tpg->compose.height; h++) { for (h = 0; h < tpg->compose.height; h++) {
bool even; bool even;
...@@ -1640,8 +1650,8 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 ...@@ -1640,8 +1650,8 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8
buf_line /= vdiv; buf_line /= vdiv;
} }
if (h >= hmax) { if (h >= params.hmax) {
if (hmax == tpg->compose.height) if (params.hmax == tpg->compose.height)
continue; continue;
if (!tpg->perc_fill_blank) if (!tpg->perc_fill_blank)
continue; continue;
...@@ -1724,7 +1734,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 ...@@ -1724,7 +1734,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8
} }
if (tpg->field_alternate) { if (tpg->field_alternate) {
linestart_top = linestart_bottom = linestart_older; linestart_top = linestart_bottom = linestart_older;
} else if (is_60hz) { } else if (params.is_60hz) {
linestart_top = linestart_newer; linestart_top = linestart_newer;
linestart_bottom = linestart_older; linestart_bottom = linestart_older;
} else { } else {
...@@ -1785,7 +1795,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8 ...@@ -1785,7 +1795,7 @@ void tpg_fill_plane_buffer(struct tpg_data *tpg, v4l2_std_id std, unsigned p, u8
buf_line /= vdiv; buf_line /= vdiv;
} }
if (is_tv && !is_60hz && frame_line == 0 && wss_width) { if (params.is_tv && !params.is_60hz && frame_line == 0 && wss_width) {
/* /*
* Replace the first half of the top line of a 50 Hz frame * Replace the first half of the top line of a 50 Hz frame
* with random data to simulate a WSS signal. * with random data to simulate a WSS signal.
......
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