From: Hans Verkuil Date: Sat, 7 Mar 2015 17:23:16 +0000 (-0300) Subject: [media] vivid-tpg: add hor/vert downsampling support to tpg_gen_text X-Git-Tag: v4.1-rc1~59^2~1^2~176 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3e14e7a82c1efdd15253a67cf5dccb84b1e9b7f1;p=karo-tx-linux.git [media] vivid-tpg: add hor/vert downsampling support to tpg_gen_text This will just skip lines/pixels since color fidelity is not quite as important here as it is with the test patterns themselves. Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/platform/vivid/vivid-tpg.c b/drivers/media/platform/vivid/vivid-tpg.c index 5b3930c9dcac..f4f0b746d778 100644 --- a/drivers/media/platform/vivid/vivid-tpg.c +++ b/drivers/media/platform/vivid/vivid-tpg.c @@ -1183,24 +1183,37 @@ void tpg_gen_text(struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], div = 2; for (p = 0; p < tpg->planes; p++) { - /* Print stream time */ + unsigned vdiv = tpg->vdownsampling[p]; + unsigned hdiv = tpg->hdownsampling[p]; + + /* Print text */ #define PRINTSTR(PIXTYPE) do { \ PIXTYPE fg; \ PIXTYPE bg; \ memcpy(&fg, tpg->textfg[p], sizeof(PIXTYPE)); \ memcpy(&bg, tpg->textbg[p], sizeof(PIXTYPE)); \ \ - for (line = first; line < 16; line += step) { \ + for (line = first; line < 16; line += vdiv * step) { \ int l = tpg->vflip ? 15 - line : line; \ - PIXTYPE *pos = (PIXTYPE *)(basep[p][line & 1] + \ - ((y * step + l) / div) * tpg->bytesperline[p] + \ - x * sizeof(PIXTYPE)); \ + PIXTYPE *pos = (PIXTYPE *)(basep[p][(line / vdiv) & 1] + \ + ((y * step + l) / (vdiv * div)) * tpg->bytesperline[p] + \ + (x / hdiv) * sizeof(PIXTYPE)); \ unsigned s; \ \ for (s = 0; s < len; s++) { \ u8 chr = font8x16[text[s] * 16 + line]; \ \ - if (tpg->hflip) { \ + if (hdiv == 2 && tpg->hflip) { \ + pos[3] = (chr & (0x01 << 6) ? fg : bg); \ + pos[2] = (chr & (0x01 << 4) ? fg : bg); \ + pos[1] = (chr & (0x01 << 2) ? fg : bg); \ + pos[0] = (chr & (0x01 << 0) ? fg : bg); \ + } else if (hdiv == 2) { \ + pos[0] = (chr & (0x01 << 7) ? fg : bg); \ + pos[1] = (chr & (0x01 << 5) ? fg : bg); \ + pos[2] = (chr & (0x01 << 3) ? fg : bg); \ + pos[3] = (chr & (0x01 << 1) ? fg : bg); \ + } else if (tpg->hflip) { \ pos[7] = (chr & (0x01 << 7) ? fg : bg); \ pos[6] = (chr & (0x01 << 6) ? fg : bg); \ pos[5] = (chr & (0x01 << 5) ? fg : bg); \ @@ -1220,7 +1233,7 @@ void tpg_gen_text(struct tpg_data *tpg, u8 *basep[TPG_MAX_PLANES][2], pos[7] = (chr & (0x01 << 0) ? fg : bg); \ } \ \ - pos += tpg->hflip ? -8 : 8; \ + pos += (tpg->hflip ? -8 : 8) / hdiv; \ } \ } \ } while (0)