23 #define DSS_SUBSYS_NAME "DISPC"
25 #include <linux/kernel.h>
28 #include <linux/export.h>
49 #define DISPC_SZ_REGS SZ_4K
51 #define DISPC_IRQ_MASK_ERROR (DISPC_IRQ_GFX_FIFO_UNDERFLOW | \
53 DISPC_IRQ_VID1_FIFO_UNDERFLOW | \
54 DISPC_IRQ_VID2_FIFO_UNDERFLOW | \
55 DISPC_IRQ_SYNC_LOST | \
56 DISPC_IRQ_SYNC_LOST_DIGIT)
58 #define DISPC_MAX_NR_ISRS 8
72 #define REG_GET(idx, start, end) \
73 FLD_GET(dispc_read_reg(idx), start, end)
75 #define REG_FLD_MOD(idx, val, start, end) \
76 dispc_write_reg(idx, FLD_MOD(dispc_read_reg(idx), val, start, end))
95 int *x_predecim,
int *y_predecim,
int *decim_x,
int *decim_y,
96 u16 pos_x,
unsigned long *core_clk,
bool mem_to_mem);
106 #define DISPC_MAX_NR_FIFOS 5
132 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
164 static const struct {
246 static void _omap_dispc_set_irqs(
void);
250 static inline void dispc_write_reg(
const u16 idx,
u32 val)
255 static inline u32 dispc_read_reg(
const u16 idx)
273 dispc.ctx[DISPC_##reg / sizeof(u32)] = dispc_read_reg(DISPC_##reg)
275 dispc_write_reg(DISPC_##reg, dispc.ctx[DISPC_##reg / sizeof(u32)])
277 static void dispc_save_context(
void)
281 DSSDBG(
"dispc_save_context\n");
300 SR(DEFAULT_COLOR(i));
326 SR(OVL_ATTRIBUTES(i));
327 SR(OVL_FIFO_THRESHOLD(i));
329 SR(OVL_PIXEL_INC(i));
333 SR(OVL_WINDOW_SKIP(i));
338 SR(OVL_PICTURE_SIZE(i));
342 for (j = 0; j < 8; j++)
343 SR(OVL_FIR_COEF_H(i, j));
345 for (j = 0; j < 8; j++)
346 SR(OVL_FIR_COEF_HV(i, j));
348 for (j = 0; j < 5; j++)
349 SR(OVL_CONV_COEF(i, j));
352 for (j = 0; j < 8; j++)
353 SR(OVL_FIR_COEF_V(i, j));
363 for (j = 0; j < 8; j++)
364 SR(OVL_FIR_COEF_H2(i, j));
366 for (j = 0; j < 8; j++)
367 SR(OVL_FIR_COEF_HV2(i, j));
369 for (j = 0; j < 8; j++)
370 SR(OVL_FIR_COEF_V2(i, j));
373 SR(OVL_ATTRIBUTES2(i));
380 dispc.ctx_valid =
true;
382 DSSDBG(
"context saved, ctx_loss_count %d\n", dispc.ctx_loss_cnt);
385 static void dispc_restore_context(
void)
389 DSSDBG(
"dispc_restore_context\n");
391 if (!dispc.ctx_valid)
396 if (ctx >= 0 && ctx == dispc.ctx_loss_cnt)
399 DSSDBG(
"ctx_loss_count: saved %d, current %d\n",
400 dispc.ctx_loss_cnt, ctx);
415 RR(DEFAULT_COLOR(i));
441 RR(OVL_ATTRIBUTES(i));
442 RR(OVL_FIFO_THRESHOLD(i));
444 RR(OVL_PIXEL_INC(i));
448 RR(OVL_WINDOW_SKIP(i));
453 RR(OVL_PICTURE_SIZE(i));
457 for (j = 0; j < 8; j++)
458 RR(OVL_FIR_COEF_H(i, j));
460 for (j = 0; j < 8; j++)
461 RR(OVL_FIR_COEF_HV(i, j));
463 for (j = 0; j < 5; j++)
464 RR(OVL_CONV_COEF(i, j));
467 for (j = 0; j < 8; j++)
468 RR(OVL_FIR_COEF_V(i, j));
478 for (j = 0; j < 8; j++)
479 RR(OVL_FIR_COEF_H2(i, j));
481 for (j = 0; j < 8; j++)
482 RR(OVL_FIR_COEF_HV2(i, j));
484 for (j = 0; j < 8; j++)
485 RR(OVL_FIR_COEF_V2(i, j));
488 RR(OVL_ATTRIBUTES2(i));
509 DSSDBG(
"context restored\n");
519 DSSDBG(
"dispc_runtime_get\n");
521 r = pm_runtime_get_sync(&dispc.pdev->dev);
523 return r < 0 ? r : 0;
530 DSSDBG(
"dispc_runtime_put\n");
532 r = pm_runtime_put_sync(&dispc.pdev->dev);
538 return mgr_desc[
channel].vsync_irq;
543 return mgr_desc[
channel].framedone_irq;
558 bool enable_bit, go_bit;
569 DSSERR(
"GO bit not down for channel %d\n", channel);
595 DSSERR(
"GO bit not down for WB\n");
607 static void dispc_ovl_write_firhv_reg(
enum omap_plane plane,
int reg,
u32 value)
612 static void dispc_ovl_write_firv_reg(
enum omap_plane plane,
int reg,
u32 value)
617 static void dispc_ovl_write_firh2_reg(
enum omap_plane plane,
int reg,
u32 value)
624 static void dispc_ovl_write_firhv2_reg(
enum omap_plane plane,
int reg,
632 static void dispc_ovl_write_firv2_reg(
enum omap_plane plane,
int reg,
u32 value)
639 static void dispc_ovl_set_scale_coef(
enum omap_plane plane,
int fir_hinc,
640 int fir_vinc,
int five_taps,
649 for (i = 0; i < 8; i++) {
662 dispc_ovl_write_firh_reg(plane, i, h);
663 dispc_ovl_write_firhv_reg(plane, i, hv);
665 dispc_ovl_write_firh2_reg(plane, i, h);
666 dispc_ovl_write_firhv2_reg(plane, i, hv);
672 for (i = 0; i < 8; i++) {
677 dispc_ovl_write_firv_reg(plane, i, v);
679 dispc_ovl_write_firv2_reg(plane, i, v);
685 static void dispc_ovl_write_color_conv_coef(
enum omap_plane plane,
688 #define CVAL(x, y) (FLD_VAL(x, 26, 16) | FLD_VAL(y, 10, 0))
701 static void dispc_setup_color_conv_coef(
void)
707 298, 409, 0, 298, -208, -100, 298, 0, 517, 0,
710 66, 112, -38, 129, -94, -74, 25, -18, 112, 0,
713 for (i = 1; i < num_ovl; i++)
714 dispc_ovl_write_color_conv_coef(i, &ctbl_bt601_5_ovl);
716 for (; i < num_wb; i++)
717 dispc_ovl_write_color_conv_coef(i, &ctbl_bt601_5_wb);
725 static void dispc_ovl_set_ba1(
enum omap_plane plane,
u32 paddr)
730 static void dispc_ovl_set_ba0_uv(
enum omap_plane plane,
u32 paddr)
735 static void dispc_ovl_set_ba1_uv(
enum omap_plane plane,
u32 paddr)
740 static void dispc_ovl_set_pos(
enum omap_plane plane,
764 static void dispc_ovl_set_output_size(
enum omap_plane plane,
int width,
779 static void dispc_ovl_set_zorder(
enum omap_plane plane,
788 static void dispc_ovl_enable_zorder_planes(
void)
799 static void dispc_ovl_set_pre_mult_alpha(
enum omap_plane plane,
808 static void dispc_ovl_setup_global_alpha(
enum omap_plane plane,
811 static const unsigned shifts[] = { 0, 8, 16, 24, };
817 shift = shifts[
plane];
826 static void dispc_ovl_set_row_inc(
enum omap_plane plane,
s32 inc)
831 static void dispc_ovl_set_color_mode(
enum omap_plane plane,
836 switch (color_mode) {
871 switch (color_mode) {
912 static void dispc_ovl_configure_burst_type(
enum omap_plane plane,
928 int chan = 0, chan2 = 0;
973 val =
FLD_MOD(val, chan, shift, shift);
974 val =
FLD_MOD(val, chan2, 31, 30);
976 val =
FLD_MOD(val, channel, shift, shift);
1004 if (
FLD_GET(val, 31, 30) == 0)
1005 channel =
FLD_GET(val, shift, shift);
1006 else if (
FLD_GET(val, 31, 30) == 1)
1011 if (
FLD_GET(val, 31, 30) == 0)
1012 channel =
FLD_GET(val, shift, shift);
1016 channel =
FLD_GET(val, shift, shift);
1029 static void dispc_ovl_set_burst_size(
enum omap_plane plane,
1032 static const unsigned shifts[] = { 6, 14, 14, 14, 14, };
1035 shift = shifts[
plane];
1039 static void dispc_configure_burst_sizes(
void)
1046 dispc_ovl_set_burst_size(i, burst_size);
1063 DSSWARN(
"Gamma table enabling for TV not yet supported");
1070 static void dispc_mgr_enable_cpr(
enum omap_channel channel,
bool enable)
1078 static void dispc_mgr_set_cpr_coef(
enum omap_channel channel,
1081 u32 coef_r, coef_g, coef_b;
1083 if (!dss_mgr_is_lcd(channel))
1093 dispc_write_reg(DISPC_CPR_COEF_R(channel), coef_r);
1094 dispc_write_reg(DISPC_CPR_COEF_G(channel), coef_g);
1095 dispc_write_reg(DISPC_CPR_COEF_B(channel), coef_b);
1098 static void dispc_ovl_set_vid_color_conv(
enum omap_plane plane,
bool enable)
1105 val =
FLD_MOD(val, enable, 9, 9);
1109 static void dispc_ovl_enable_replication(
enum omap_plane plane,
1112 static const unsigned shifts[] = { 5, 10, 10, 10 };
1118 shift = shifts[
plane];
1128 dispc_write_reg(DISPC_SIZE_MGR(channel), val);
1131 static void dispc_init_fifos(
void)
1142 for (fifo = 0; fifo < dispc.feat->num_fifos; ++fifo) {
1145 dispc.fifo_size[fifo] =
size;
1151 dispc.fifo_assignment[fifo] = fifo;
1161 if (dispc.feat->gfx_fifo_workaround) {
1183 for (fifo = 0; fifo < dispc.feat->num_fifos; ++fifo) {
1184 if (dispc.fifo_assignment[fifo] == plane)
1185 size += dispc.fifo_size[fifo];
1193 u8 hi_start, hi_end, lo_start, lo_end;
1207 DSSDBG(
"fifo(%d) threshold (bytes), old %u/%u, new %u/%u\n",
1210 lo_start, lo_end) * unit,
1212 hi_start, hi_end) * unit,
1213 low * unit, high * unit);
1216 FLD_VAL(high, hi_start, hi_end) |
1217 FLD_VAL(low, lo_start, lo_end));
1227 DSSDBG(
"FIFO merge %s\n", enable ?
"enabled" :
"disabled");
1232 u32 *fifo_low,
u32 *fifo_high,
bool use_fifomerge,
1241 unsigned ovl_fifo_size, total_fifo_size, burst_size;
1244 burst_size = dispc_ovl_get_burst_size(plane);
1245 ovl_fifo_size = dispc_ovl_get_fifo_size(plane);
1247 if (use_fifomerge) {
1248 total_fifo_size = 0;
1250 total_fifo_size += dispc_ovl_get_fifo_size(i);
1252 total_fifo_size = ovl_fifo_size;
1262 *fifo_low = ovl_fifo_size - burst_size * 2;
1263 *fifo_high = total_fifo_size - burst_size;
1271 *fifo_high = burst_size;
1273 *fifo_low = ovl_fifo_size - burst_size;
1274 *fifo_high = total_fifo_size - buf_unit;
1278 static void dispc_ovl_set_fir(
enum omap_plane plane,
1285 u8 hinc_start, hinc_end, vinc_start, vinc_end;
1288 &hinc_start, &hinc_end);
1290 &vinc_start, &vinc_end);
1291 val =
FLD_VAL(vinc, vinc_start, vinc_end) |
1292 FLD_VAL(hinc, hinc_start, hinc_end);
1301 static void dispc_ovl_set_vid_accu0(
enum omap_plane plane,
int haccu,
int vaccu)
1304 u8 hor_start, hor_end, vert_start, vert_end;
1309 val =
FLD_VAL(vaccu, vert_start, vert_end) |
1310 FLD_VAL(haccu, hor_start, hor_end);
1315 static void dispc_ovl_set_vid_accu1(
enum omap_plane plane,
int haccu,
int vaccu)
1318 u8 hor_start, hor_end, vert_start, vert_end;
1323 val =
FLD_VAL(vaccu, vert_start, vert_end) |
1324 FLD_VAL(haccu, hor_start, hor_end);
1329 static void dispc_ovl_set_vid_accu2_0(
enum omap_plane plane,
int haccu,
1338 static void dispc_ovl_set_vid_accu2_1(
enum omap_plane plane,
int haccu,
1347 static void dispc_ovl_set_scale_param(
enum omap_plane plane,
1348 u16 orig_width,
u16 orig_height,
1349 u16 out_width,
u16 out_height,
1350 bool five_taps,
u8 rotation,
1353 int fir_hinc, fir_vinc;
1355 fir_hinc = 1024 * orig_width / out_width;
1356 fir_vinc = 1024 * orig_height / out_height;
1358 dispc_ovl_set_scale_coef(plane, fir_hinc, fir_vinc, five_taps,
1360 dispc_ovl_set_fir(plane, fir_hinc, fir_vinc, color_comp);
1363 static void dispc_ovl_set_accu_uv(
enum omap_plane plane,
1364 u16 orig_width,
u16 orig_height,
u16 out_width,
u16 out_height,
1367 int h_accu2_0, h_accu2_1;
1368 int v_accu2_0, v_accu2_1;
1369 int chroma_hinc, chroma_vinc;
1379 const struct accu *accu_table;
1380 const struct accu *accu_val;
1382 static const struct accu accu_nv12[4] = {
1383 { 0, 1, 0, 1 , -1, 2, 0, 1 },
1384 { 1, 2, -3, 4 , 0, 1, 0, 1 },
1385 { -1, 1, 0, 1 , -1, 2, 0, 1 },
1386 { -1, 2, -1, 2 , -1, 1, 0, 1 },
1389 static const struct accu accu_nv12_ilace[4] = {
1390 { 0, 1, 0, 1 , -3, 4, -1, 4 },
1391 { -1, 4, -3, 4 , 0, 1, 0, 1 },
1392 { -1, 1, 0, 1 , -1, 4, -3, 4 },
1393 { -3, 4, -3, 4 , -1, 1, 0, 1 },
1396 static const struct accu accu_yuv[4] = {
1397 { 0, 1, 0, 1, 0, 1, 0, 1 },
1398 { 0, 1, 0, 1, 0, 1, 0, 1 },
1399 { -1, 1, 0, 1, 0, 1, 0, 1 },
1400 { 0, 1, 0, 1, -1, 1, 0, 1 },
1421 switch (color_mode) {
1424 accu_table = accu_nv12_ilace;
1426 accu_table = accu_nv12;
1430 accu_table = accu_yuv;
1437 accu_val = &accu_table[
idx];
1439 chroma_hinc = 1024 * orig_width / out_width;
1440 chroma_vinc = 1024 * orig_height / out_height;
1442 h_accu2_0 = (accu_val->h0_m * chroma_hinc / accu_val->h0_n) % 1024;
1443 h_accu2_1 = (accu_val->h1_m * chroma_hinc / accu_val->h1_n) % 1024;
1444 v_accu2_0 = (accu_val->v0_m * chroma_vinc / accu_val->v0_n) % 1024;
1445 v_accu2_1 = (accu_val->v1_m * chroma_vinc / accu_val->v1_n) % 1024;
1447 dispc_ovl_set_vid_accu2_0(plane, h_accu2_0, v_accu2_0);
1448 dispc_ovl_set_vid_accu2_1(plane, h_accu2_1, v_accu2_1);
1451 static void dispc_ovl_set_scaling_common(
enum omap_plane plane,
1452 u16 orig_width,
u16 orig_height,
1453 u16 out_width,
u16 out_height,
1454 bool ilace,
bool five_taps,
1462 dispc_ovl_set_scale_param(plane, orig_width, orig_height,
1463 out_width, out_height, five_taps,
1468 l &= ~((0x3 << 5) | (0x1 << 21));
1469 l |= (orig_width != out_width) ? (1 << 5) : 0;
1470 l |= (orig_height != out_height) ? (1 << 6) : 0;
1471 l |= five_taps ? (1 << 21) : 0;
1476 l |= (orig_width <= out_width) ? 0 : (1 << 7);
1477 l |= (orig_height <= out_height) ? 0 : (1 << 8);
1483 l |= five_taps ? (1 << 22) : 0;
1492 if (ilace && !fieldmode) {
1494 accu0 = ((1024 * orig_height / out_height) / 2) & 0x3ff;
1495 if (accu0 >= 1024/2) {
1501 dispc_ovl_set_vid_accu0(plane, 0, accu0);
1502 dispc_ovl_set_vid_accu1(plane, 0, accu1);
1505 static void dispc_ovl_set_scaling_uv(
enum omap_plane plane,
1506 u16 orig_width,
u16 orig_height,
1507 u16 out_width,
u16 out_height,
1508 bool ilace,
bool five_taps,
1512 int scale_x = out_width != orig_width;
1513 int scale_y = out_height != orig_height;
1514 bool chroma_upscale = plane !=
OMAP_DSS_WB ?
true :
false;
1527 dispc_ovl_set_accu_uv(plane, orig_width, orig_height, out_width,
1528 out_height, ilace, color_mode, rotation);
1530 switch (color_mode) {
1532 if (chroma_upscale) {
1558 scale_x = scale_y =
true;
1566 if (out_width != orig_width)
1568 if (out_height != orig_height)
1571 dispc_ovl_set_scale_param(plane, orig_width, orig_height,
1572 out_width, out_height, five_taps,
1577 (scale_x || scale_y) ? 1 : 0, 8, 8);
1585 static void dispc_ovl_set_scaling(
enum omap_plane plane,
1586 u16 orig_width,
u16 orig_height,
1587 u16 out_width,
u16 out_height,
1588 bool ilace,
bool five_taps,
1594 dispc_ovl_set_scaling_common(plane,
1595 orig_width, orig_height,
1596 out_width, out_height,
1598 fieldmode, color_mode,
1601 dispc_ovl_set_scaling_uv(plane,
1602 orig_width, orig_height,
1603 out_width, out_height,
1605 fieldmode, color_mode,
1609 static void dispc_ovl_set_rotation_attrs(
enum omap_plane plane,
u8 rotation,
1612 bool row_repeat =
false;
1659 row_repeat ? 1 : 0, 18, 18);
1664 switch (color_mode) {
1697 static s32 pixinc(
int pixels,
u8 ps)
1701 else if (pixels > 1)
1702 return 1 + (pixels - 1) * ps;
1703 else if (pixels < 0)
1704 return 1 - (-pixels + 1) * ps;
1710 static void calc_vrfb_rotation_offset(
u8 rotation,
bool mirror,
1714 unsigned int field_offset,
1715 unsigned *offset0,
unsigned *
offset1,
1716 s32 *row_inc,
s32 *pix_inc,
int x_predecim,
int y_predecim)
1721 switch (color_mode) {
1733 ps = color_mode_to_bpp(color_mode) / 8;
1737 DSSDBG(
"calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width,
1744 switch (rotation + mirror * 4) {
1758 *offset0 = field_offset * screen_width *
ps;
1762 *row_inc = pixinc(1 +
1763 (y_predecim * screen_width - x_predecim * width) +
1764 (fieldmode ? screen_width : 0), ps);
1765 *pix_inc = pixinc(x_predecim, ps);
1780 *offset0 = field_offset * screen_width *
ps;
1783 *row_inc = pixinc(1 -
1784 (y_predecim * screen_width + x_predecim * width) -
1785 (fieldmode ? screen_width : 0), ps);
1786 *pix_inc = pixinc(x_predecim, ps);
1795 static void calc_dma_rotation_offset(
u8 rotation,
bool mirror,
1799 unsigned int field_offset,
1800 unsigned *offset0,
unsigned *offset1,
1801 s32 *row_inc,
s32 *pix_inc,
int x_predecim,
int y_predecim)
1807 switch (color_mode) {
1815 ps = color_mode_to_bpp(color_mode) / 8;
1819 DSSDBG(
"calc_rot(%d): scrw %d, %dx%d\n", rotation, screen_width,
1836 switch (rotation + mirror * 4) {
1840 *offset0 = *offset1 + field_offset * screen_width *
ps;
1843 *row_inc = pixinc(1 +
1844 (y_predecim * screen_width - fbw * x_predecim) +
1845 (fieldmode ? screen_width : 0), ps);
1848 *pix_inc = pixinc(x_predecim, 2 * ps);
1850 *pix_inc = pixinc(x_predecim, ps);
1853 *offset1 = screen_width * (fbh - 1) * ps;
1855 *offset0 = *offset1 + field_offset *
ps;
1858 *row_inc = pixinc(screen_width * (fbh * x_predecim - 1) +
1859 y_predecim + (fieldmode ? 1 : 0), ps);
1860 *pix_inc = pixinc(-x_predecim * screen_width, ps);
1863 *offset1 = (screen_width * (fbh - 1) + fbw - 1) *
ps;
1865 *offset0 = *offset1 - field_offset * screen_width *
ps;
1868 *row_inc = pixinc(-1 -
1869 (y_predecim * screen_width - fbw * x_predecim) -
1870 (fieldmode ? screen_width : 0), ps);
1873 *pix_inc = pixinc(-x_predecim, 2 * ps);
1875 *pix_inc = pixinc(-x_predecim, ps);
1878 *offset1 = (fbw - 1) * ps;
1880 *offset0 = *offset1 - field_offset *
ps;
1883 *row_inc = pixinc(-screen_width * (fbh * x_predecim - 1) -
1884 y_predecim - (fieldmode ? 1 : 0), ps);
1885 *pix_inc = pixinc(x_predecim * screen_width, ps);
1890 *offset1 = (fbw - 1) * ps;
1892 *offset0 = *offset1 + field_offset * screen_width *
ps;
1895 *row_inc = pixinc(y_predecim * screen_width * 2 - 1 +
1896 (fieldmode ? screen_width : 0),
1900 *pix_inc = pixinc(-x_predecim, 2 * ps);
1902 *pix_inc = pixinc(-x_predecim, ps);
1908 *offset0 = *offset1 + field_offset *
ps;
1911 *row_inc = pixinc(-screen_width * (fbh * x_predecim - 1) +
1912 y_predecim + (fieldmode ? 1 : 0),
1914 *pix_inc = pixinc(x_predecim * screen_width, ps);
1918 *offset1 = screen_width * (fbh - 1) * ps;
1920 *offset0 = *offset1 - field_offset * screen_width *
ps;
1923 *row_inc = pixinc(1 - y_predecim * screen_width * 2 -
1924 (fieldmode ? screen_width : 0),
1928 *pix_inc = pixinc(x_predecim, 2 * ps);
1930 *pix_inc = pixinc(x_predecim, ps);
1934 *offset1 = (screen_width * (fbh - 1) + fbw - 1) *
ps;
1936 *offset0 = *offset1 - field_offset *
ps;
1939 *row_inc = pixinc(screen_width * (fbh * x_predecim - 1) -
1940 y_predecim - (fieldmode ? 1 : 0),
1942 *pix_inc = pixinc(-x_predecim * screen_width, ps);
1951 static void calc_tiler_rotation_offset(
u16 screen_width,
u16 width,
1953 unsigned int field_offset,
unsigned *offset0,
unsigned *offset1,
1954 s32 *row_inc,
s32 *pix_inc,
int x_predecim,
int y_predecim)
1958 switch (color_mode) {
1966 ps = color_mode_to_bpp(color_mode) / 8;
1970 DSSDBG(
"scrw %d, width %d\n", screen_width, width);
1978 *offset0 = *offset1 + field_offset * screen_width *
ps;
1981 *row_inc = pixinc(1 + (y_predecim * screen_width - width * x_predecim) +
1982 (fieldmode ? screen_width : 0), ps);
1985 *pix_inc = pixinc(x_predecim, 2 * ps);
1987 *pix_inc = pixinc(x_predecim, ps);
1994 static int check_horiz_timing_omap3(
enum omap_plane plane,
1999 unsigned long nonactive;
2000 static const u8 limits[3] = { 8, 10, 20 };
2002 unsigned long pclk = dispc_plane_pclk_rate(plane);
2003 unsigned long lclk = dispc_plane_lclk_rate(plane);
2009 if (out_height < height)
2011 if (out_width < width)
2013 blank = div_u64((
u64)(t->
hbp + t->
hsw + t->
hfp) * lclk, pclk);
2014 DSSDBG(
"blanking period + ppl = %llu (limit = %u)\n", blank, limits[i]);
2015 if (blank <= limits[i])
2023 val = div_u64((
u64)(nonactive - pos_x) * lclk, pclk);
2024 DSSDBG(
"(nonactive - pos_x) * pcd = %llu max(0, DS - 2) * width = %d\n",
2025 val,
max(0, DS - 2) * width);
2026 if (val <
max(0, DS - 2) * width)
2034 val = div_u64((
u64)nonactive * lclk, pclk);
2035 DSSDBG(
"nonactive * pcd = %llu, max(0, DS - 1) * width = %d\n",
2036 val,
max(0, DS - 1) * width);
2037 if (val <
max(0, DS - 1) * width)
2043 static unsigned long calc_core_clk_five_taps(
enum omap_plane plane,
2045 u16 height,
u16 out_width,
u16 out_height,
2050 unsigned long pclk = dispc_plane_pclk_rate(plane);
2052 if (height <= out_height && width <= out_width)
2053 return (
unsigned long) pclk;
2055 if (height > out_height) {
2056 unsigned int ppl = mgr_timings->
x_res;
2058 tmp = pclk * height * out_width;
2059 do_div(tmp, 2 * out_height * ppl);
2062 if (height > 2 * out_height) {
2063 if (ppl == out_width)
2066 tmp = pclk * (height - 2 * out_height) * out_width;
2067 do_div(tmp, 2 * out_height * (ppl - out_width));
2068 core_clk =
max_t(
u32, core_clk, tmp);
2072 if (width > out_width) {
2075 core_clk =
max_t(
u32, core_clk, tmp);
2084 static unsigned long calc_core_clk_24xx(
enum omap_plane plane,
u16 width,
2085 u16 height,
u16 out_width,
u16 out_height,
bool mem_to_mem)
2087 unsigned long pclk = dispc_plane_pclk_rate(plane);
2089 if (height > out_height && width > out_width)
2095 static unsigned long calc_core_clk_34xx(
enum omap_plane plane,
u16 width,
2096 u16 height,
u16 out_width,
u16 out_height,
bool mem_to_mem)
2098 unsigned int hf,
vf;
2099 unsigned long pclk = dispc_plane_pclk_rate(plane);
2106 if (width > 3 * out_width)
2108 else if (width > 2 * out_width)
2110 else if (width > out_width)
2114 if (height > out_height)
2119 return pclk * vf * hf;
2122 static unsigned long calc_core_clk_44xx(
enum omap_plane plane,
u16 width,
2123 u16 height,
u16 out_width,
u16 out_height,
bool mem_to_mem)
2136 pclk = dispc_plane_pclk_rate(plane);
2138 if (width > out_width)
2144 static int dispc_ovl_calc_scaling_24xx(
enum omap_plane plane,
2148 int *x_predecim,
int *y_predecim,
int *decim_x,
int *decim_y,
2149 u16 pos_x,
unsigned long *core_clk,
bool mem_to_mem)
2152 u16 in_width, in_height;
2153 int min_factor =
min(*decim_x, *decim_y);
2154 const int maxsinglelinewidth =
2162 *core_clk = dispc.feat->calc_core_clk(plane, in_width,
2163 in_height, out_width, out_height, mem_to_mem);
2164 error = (in_width > maxsinglelinewidth || !*core_clk ||
2167 if (*decim_x == *decim_y) {
2168 *decim_x = min_factor;
2171 swap(*decim_x, *decim_y);
2172 if (*decim_x < *decim_y)
2176 }
while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
2178 if (in_width > maxsinglelinewidth) {
2179 DSSERR(
"Cannot scale max input width exceeded");
2185 static int dispc_ovl_calc_scaling_34xx(
enum omap_plane plane,
2189 int *x_predecim,
int *y_predecim,
int *decim_x,
int *decim_y,
2190 u16 pos_x,
unsigned long *core_clk,
bool mem_to_mem)
2193 u16 in_width, in_height;
2194 int min_factor =
min(*decim_x, *decim_y);
2195 const int maxsinglelinewidth =
2201 *core_clk = calc_core_clk_five_taps(plane, mgr_timings,
2202 in_width, in_height, out_width, out_height, color_mode);
2204 error = check_horiz_timing_omap3(plane, mgr_timings,
2205 pos_x, in_width, in_height, out_width,
2208 if (in_width > maxsinglelinewidth)
2209 if (in_height > out_height &&
2210 in_height < out_height * 2)
2213 *core_clk = dispc.feat->calc_core_clk(plane, in_width,
2214 in_height, out_width, out_height,
2217 error = (error || in_width > maxsinglelinewidth * 2 ||
2218 (in_width > maxsinglelinewidth && *five_taps) ||
2221 if (*decim_x == *decim_y) {
2222 *decim_x = min_factor;
2225 swap(*decim_x, *decim_y);
2226 if (*decim_x < *decim_y)
2230 }
while (*decim_x <= *x_predecim && *decim_y <= *y_predecim && error);
2232 if (check_horiz_timing_omap3(plane, mgr_timings, pos_x, width, height,
2233 out_width, out_height)){
2234 DSSERR(
"horizontal timing too tight\n");
2238 if (in_width > (maxsinglelinewidth * 2)) {
2239 DSSERR(
"Cannot setup scaling");
2240 DSSERR(
"width exceeds maximum width possible");
2244 if (in_width > maxsinglelinewidth && *five_taps) {
2245 DSSERR(
"cannot setup scaling with five taps");
2251 static int dispc_ovl_calc_scaling_44xx(
enum omap_plane plane,
2255 int *x_predecim,
int *y_predecim,
int *decim_x,
int *decim_y,
2256 u16 pos_x,
unsigned long *core_clk,
bool mem_to_mem)
2258 u16 in_width, in_width_max;
2259 int decim_x_min = *decim_x;
2261 const int maxsinglelinewidth =
2263 unsigned long pclk = dispc_plane_pclk_rate(plane);
2274 *decim_x = *decim_x > decim_x_min ? *decim_x : decim_x_min;
2275 if (*decim_x > *x_predecim)
2280 }
while (*decim_x <= *x_predecim &&
2281 in_width > maxsinglelinewidth && ++*decim_x);
2283 if (in_width > maxsinglelinewidth) {
2284 DSSERR(
"Cannot scale width exceeds max line width");
2288 *core_clk = dispc.feat->calc_core_clk(plane, in_width, in_height,
2289 out_width, out_height, mem_to_mem);
2293 static int dispc_ovl_calc_scaling(
enum omap_plane plane,
2298 int *x_predecim,
int *y_predecim,
u16 pos_x,
2302 const int max_decim_limit = 16;
2303 unsigned long core_clk = 0;
2304 int decim_x, decim_y,
ret;
2306 if (width == out_width && height == out_height)
2312 *x_predecim = max_decim_limit;
2329 if (decim_x > *x_predecim || out_width > width * 8)
2332 if (decim_y > *y_predecim || out_height > height * 8)
2335 ret = dispc.feat->calc_scaling(plane, mgr_timings, width, height,
2336 out_width, out_height, color_mode, five_taps,
2337 x_predecim, y_predecim, &decim_x, &decim_y, pos_x, &core_clk,
2342 DSSDBG(
"required core clk rate = %lu Hz\n", core_clk);
2346 DSSERR(
"failed to set up scaling, "
2347 "required core clk rate = %lu Hz, "
2348 "current core clk rate = %lu Hz\n",
2353 *x_predecim = decim_x;
2354 *y_predecim = decim_y;
2358 static int dispc_ovl_setup_common(
enum omap_plane plane,
2360 u16 screen_width,
int pos_x,
int pos_y,
u16 width,
u16 height,
2362 u8 rotation,
bool mirror,
u8 zorder,
u8 pre_mult_alpha,
2367 bool five_taps =
true;
2374 unsigned int field_offset = 0;
2377 int x_predecim = 1, y_predecim = 1;
2383 out_width = out_width == 0 ? width : out_width;
2384 out_height = out_height == 0 ? height : out_height;
2386 if (ilace && height == out_height)
2395 DSSDBG(
"adjusting for ilace: height %d, pos_y %d, "
2396 "out_height %d\n", in_height, pos_y,
2403 r = dispc_ovl_calc_scaling(plane, caps, mgr_timings, in_width,
2404 in_height, out_width, out_height, color_mode,
2405 &five_taps, &x_predecim, &y_predecim, pos_x,
2406 rotation_type, mem_to_mem);
2418 if (ilace && !fieldmode) {
2426 if (!in_height || in_height == out_height)
2429 field_offset = in_height / out_height / 2;
2442 calc_tiler_rotation_offset(screen_width, in_width,
2443 color_mode, fieldmode, field_offset,
2444 &offset0, &offset1, &row_inc, &pix_inc,
2445 x_predecim, y_predecim);
2447 calc_dma_rotation_offset(rotation, mirror,
2448 screen_width, in_width, frame_height,
2449 color_mode, fieldmode, field_offset,
2450 &offset0, &offset1, &row_inc, &pix_inc,
2451 x_predecim, y_predecim);
2453 calc_vrfb_rotation_offset(rotation, mirror,
2454 screen_width, in_width, frame_height,
2455 color_mode, fieldmode, field_offset,
2456 &offset0, &offset1, &row_inc, &pix_inc,
2457 x_predecim, y_predecim);
2459 DSSDBG(
"offset0 %u, offset1 %u, row_inc %d, pix_inc %d\n",
2460 offset0, offset1, row_inc, pix_inc);
2462 dispc_ovl_set_color_mode(plane, color_mode);
2464 dispc_ovl_configure_burst_type(plane, rotation_type);
2466 dispc_ovl_set_ba0(plane, paddr + offset0);
2467 dispc_ovl_set_ba1(plane, paddr + offset1);
2470 dispc_ovl_set_ba0_uv(plane, p_uv_addr + offset0);
2471 dispc_ovl_set_ba1_uv(plane, p_uv_addr + offset1);
2474 dispc_ovl_set_row_inc(plane, row_inc);
2475 dispc_ovl_set_pix_inc(plane, pix_inc);
2477 DSSDBG(
"%d,%d %dx%d -> %dx%d\n", pos_x, pos_y, in_width,
2478 in_height, out_width, out_height);
2480 dispc_ovl_set_pos(plane, caps, pos_x, pos_y);
2482 dispc_ovl_set_input_size(plane, in_width, in_height);
2484 if (caps & OMAP_DSS_OVL_CAP_SCALE) {
2485 dispc_ovl_set_scaling(plane, in_width, in_height, out_width,
2486 out_height, ilace, five_taps, fieldmode,
2487 color_mode, rotation);
2488 dispc_ovl_set_output_size(plane, out_width, out_height);
2489 dispc_ovl_set_vid_color_conv(plane, cconv);
2492 dispc_ovl_set_rotation_attrs(plane, rotation, mirror, color_mode);
2494 dispc_ovl_set_zorder(plane, caps, zorder);
2495 dispc_ovl_set_pre_mult_alpha(plane, caps, pre_mult_alpha);
2496 dispc_ovl_setup_global_alpha(plane, caps, global_alpha);
2498 dispc_ovl_enable_replication(plane, caps, replication);
2511 channel = dispc_ovl_get_channel_out(plane);
2513 DSSDBG(
"dispc_ovl_setup %d, pa %x, pa_uv %x, sw %d, %d,%d, %dx%d -> "
2514 "%dx%d, cmode %x, rot %d, mir %d, chan %d repl %d\n",
2534 const int pos_x = 0, pos_y = 0;
2535 const u8 zorder = 0, global_alpha = 0;
2536 const bool replication =
false;
2538 int in_width = mgr_timings->
x_res;
2539 int in_height = mgr_timings->
y_res;
2543 DSSDBG(
"dispc_wb_setup, pa %x, pa_uv %x, %d,%d -> %dx%d, cmode %x, "
2548 r = dispc_ovl_setup_common(plane, caps, wi->
paddr, wi->
p_uv_addr,
2552 replication, mgr_timings, mem_to_mem);
2572 l =
FLD_MOD(l, truncation, 10, 10);
2573 l =
FLD_MOD(l, mem_to_mem, 19, 19);
2581 DSSDBG(
"dispc_enable_plane %d, %d\n", plane, enable);
2588 static void dispc_disable_isr(
void *
data,
u32 mask)
2594 static void _enable_lcd_out(
enum omap_channel channel,
bool enable)
2601 static void dispc_mgr_enable_lcd_out(
enum omap_channel channel,
bool enable)
2613 irq = mgr_desc[
channel].framedone_irq;
2615 if (!enable && is_on) {
2616 init_completion(&frame_done_completion);
2619 &frame_done_completion, irq);
2622 DSSERR(
"failed to register FRAMEDONE isr\n");
2625 _enable_lcd_out(channel, enable);
2627 if (!enable && is_on) {
2630 DSSERR(
"timeout waiting for FRAME DONE\n");
2633 &frame_done_completion, irq);
2636 DSSERR(
"failed to unregister FRAMEDONE isr\n");
2640 static void _enable_digit_out(
bool enable)
2647 static void dispc_mgr_enable_digit_out(
bool enable)
2661 unsigned long flags;
2666 _omap_dispc_set_irqs();
2667 spin_unlock_irqrestore(&dispc.irq_lock, flags);
2674 init_completion(&frame_done_completion);
2690 DSSERR(
"failed to register %x isr\n", irq_mask);
2692 _enable_digit_out(enable);
2697 DSSERR(
"timeout waiting for digit out to %s\n",
2698 enable ?
"start" :
"stop");
2704 DSSERR(
"failed to unregister %x isr\n", irq_mask);
2707 unsigned long flags;
2711 _omap_dispc_set_irqs();
2712 spin_unlock_irqrestore(&dispc.irq_lock, flags);
2723 if (dss_mgr_is_lcd(channel))
2724 dispc_mgr_enable_lcd_out(channel, enable);
2726 dispc_mgr_enable_digit_out(enable);
2742 if (!enable && is_on) {
2743 init_completion(&frame_done_completion);
2746 &frame_done_completion, irq);
2748 DSSERR(
"failed to register FRAMEDONEWB isr\n");
2753 if (!enable && is_on) {
2756 DSSERR(
"timeout waiting for FRAMEDONEWB\n");
2759 &frame_done_completion, irq);
2761 DSSERR(
"failed to unregister FRAMEDONEWB isr\n");
2815 dispc_write_reg(DISPC_DEFAULT_COLOR(channel), color);
2818 static void dispc_mgr_set_trans_key(
enum omap_channel ch,
2824 dispc_write_reg(DISPC_TRANS_COLOR(ch), trans_key);
2827 static void dispc_mgr_enable_trans_key(
enum omap_channel ch,
bool enable)
2832 static void dispc_mgr_enable_alpha_fixed_zorder(
enum omap_channel ch,
2850 dispc_mgr_enable_alpha_fixed_zorder(channel,
2853 dispc_mgr_enable_cpr(channel, info->
cpr_enable);
2854 dispc_mgr_set_cpr_coef(channel, &info->
cpr_coefs);
2862 switch (data_lines) {
2907 l =
FLD_MOD(l, gpout0, 15, 15);
2908 l =
FLD_MOD(l, gpout1, 16, 16);
2917 static bool _dispc_mgr_size_ok(
u16 width,
u16 height)
2923 static bool _dispc_lcd_timings_ok(
int hsw,
int hfp,
int hbp,
2924 int vsw,
int vfp,
int vbp)
2926 if (hsw < 1 || hsw > dispc.feat->sw_max ||
2927 hfp < 1 || hfp > dispc.feat->hp_max ||
2928 hbp < 1 || hbp > dispc.feat->hp_max ||
2929 vsw < 1 || vsw > dispc.feat->sw_max ||
2930 vfp < 0 || vfp > dispc.feat->vp_max ||
2931 vbp < 0 || vbp > dispc.feat->vp_max)
2941 timings_ok = _dispc_mgr_size_ok(timings->
x_res, timings->
y_res);
2943 if (dss_mgr_is_lcd(channel))
2944 timings_ok = timings_ok && _dispc_lcd_timings_ok(timings->
hsw,
2945 timings->
hfp, timings->
hbp,
2946 timings->
vsw, timings->
vfp,
2952 static void _dispc_mgr_set_lcd_timings(
enum omap_channel channel,
int hsw,
2953 int hfp,
int hbp,
int vsw,
int vfp,
int vbp,
2961 u32 timing_h, timing_v,
l;
2962 bool onoff, rf, ipc;
2964 timing_h =
FLD_VAL(hsw-1, dispc.feat->sw_start, 0) |
2965 FLD_VAL(hfp-1, dispc.feat->fp_start, 8) |
2966 FLD_VAL(hbp-1, dispc.feat->bp_start, 20);
2967 timing_v =
FLD_VAL(vsw-1, dispc.feat->sw_start, 0) |
2968 FLD_VAL(vfp, dispc.feat->fp_start, 8) |
2969 FLD_VAL(vbp, dispc.feat->bp_start, 20);
2971 dispc_write_reg(DISPC_TIMING_H(channel), timing_h);
2972 dispc_write_reg(DISPC_TIMING_V(channel), timing_v);
2974 switch (data_pclk_edge) {
2986 switch (sync_pclk_edge) {
3003 l = dispc_read_reg(DISPC_POL_FREQ(channel));
3006 l |=
FLD_VAL(de_level, 15, 15);
3008 l |=
FLD_VAL(hsync_level, 13, 13);
3009 l |=
FLD_VAL(vsync_level, 12, 12);
3010 dispc_write_reg(DISPC_POL_FREQ(channel), l);
3017 unsigned xtot, ytot;
3018 unsigned long ht, vt;
3028 if (dss_mgr_is_lcd(channel)) {
3029 _dispc_mgr_set_lcd_timings(channel, t.
hsw, t.
hfp, t.
hbp, t.
vsw,
3040 DSSDBG(
"hsw %d hfp %d hbp %d vsw %d vfp %d vbp %d\n",
3042 DSSDBG(
"vsync_level %d hsync_level %d data_pclk_edge %d de_level %d sync_pclk_edge %d\n",
3046 DSSDBG(
"hsync %luHz, vsync %luHz\n", ht, vt);
3052 dispc_mgr_set_size(channel, t.
x_res, t.
y_res);
3055 static void dispc_mgr_set_lcd_divisor(
enum omap_channel channel,
u16 lck_div,
3061 dispc_write_reg(DISPC_DIVISORo(channel),
3065 static void dispc_mgr_get_lcd_divisor(
enum omap_channel channel,
int *lck_div,
3069 l = dispc_read_reg(DISPC_DIVISORo(channel));
3070 *lck_div =
FLD_GET(l, 23, 16);
3077 unsigned long r = 0;
3106 l = dispc_read_reg(DISPC_DIVISORo(channel));
3134 if (dss_mgr_is_lcd(channel)) {
3138 l = dispc_read_reg(DISPC_DIVISORo(channel));
3175 static unsigned long dispc_plane_pclk_rate(
enum omap_plane plane)
3177 enum omap_channel channel = dispc_ovl_get_channel_out(plane);
3182 static unsigned long dispc_plane_lclk_rate(
enum omap_plane plane)
3184 enum omap_channel channel = dispc_ovl_get_channel_out(plane);
3186 if (dss_mgr_is_lcd(channel))
3201 seq_printf(s,
"%s clk source = %s (%s)\n", mgr_desc[channel].
name,
3205 dispc_mgr_get_lcd_divisor(channel, &lcd, &pcd);
3224 seq_printf(s,
"dispc fclk source = %s (%s)\n",
3249 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
3250 void dispc_dump_irqs(
struct seq_file *s)
3252 unsigned long flags;
3257 stats = dispc.irq_stats;
3258 memset(&dispc.irq_stats, 0,
sizeof(dispc.irq_stats));
3259 dispc.irq_stats.last_reset =
jiffies;
3261 spin_unlock_irqrestore(&dispc.irq_stats_lock, flags);
3268 seq_printf(s, "%-20s %10d\n", #x, stats.irqs[ffs(DISPC_IRQ_##x)-1]);
3274 PIS(ACBIAS_COUNT_STAT);
3276 PIS(GFX_FIFO_UNDERFLOW);
3278 PIS(PAL_GAMMA_MASK);
3280 PIS(VID1_FIFO_UNDERFLOW);
3282 PIS(VID2_FIFO_UNDERFLOW);
3285 PIS(VID3_FIFO_UNDERFLOW);
3289 PIS(SYNC_LOST_DIGIT);
3294 PIS(ACBIAS_COUNT_STAT2);
3300 PIS(ACBIAS_COUNT_STAT3);
3307 static void dispc_dump_regs(
struct seq_file *s)
3310 const char *mgr_names[] = {
3316 const char *ovl_names[] = {
3322 const char **p_names;
3324 #define DUMPREG(r) seq_printf(s, "%-50s %08x\n", #r, dispc_read_reg(r))
3354 #define DISPC_REG(i, name) name(i)
3355 #define DUMPREG(i, r) seq_printf(s, "%s(%s)%*s %08x\n", #r, p_names[i], \
3356 48 - strlen(#r) - strlen(p_names[i]), " ", \
3357 dispc_read_reg(DISPC_REG(i, r)))
3359 p_names = mgr_names;
3363 DUMPREG(i, DISPC_DEFAULT_COLOR);
3364 DUMPREG(i, DISPC_TRANS_COLOR);
3370 DUMPREG(i, DISPC_DEFAULT_COLOR);
3371 DUMPREG(i, DISPC_TRANS_COLOR);
3378 DUMPREG(i, DISPC_DATA_CYCLE1);
3379 DUMPREG(i, DISPC_DATA_CYCLE2);
3380 DUMPREG(i, DISPC_DATA_CYCLE3);
3389 p_names = ovl_names;
3430 #define DISPC_REG(plane, name, i) name(plane, i)
3431 #define DUMPREG(plane, name, i) \
3432 seq_printf(s, "%s_%d(%s)%*s %08x\n", #name, i, p_names[plane], \
3433 46 - strlen(#name) - strlen(p_names[plane]), " ", \
3434 dispc_read_reg(DISPC_REG(plane, name, i)))
3440 for (j = 0; j < 8; j++)
3443 for (j = 0; j < 8; j++)
3446 for (j = 0; j < 5; j++)
3450 for (j = 0; j < 8; j++)
3455 for (j = 0; j < 8; j++)
3458 for (j = 0; j < 8; j++)
3461 for (j = 0; j < 8; j++)
3476 u16 pcd_min, pcd_max;
3477 unsigned long best_pck;
3478 u16 best_ld, cur_ld;
3479 u16 best_pd, cur_pd;
3488 for (cur_ld = 1; cur_ld <= 255; ++cur_ld) {
3489 unsigned long lck = fck / cur_ld;
3491 for (cur_pd = pcd_min; cur_pd <= pcd_max; ++cur_pd) {
3492 unsigned long pck = lck / cur_pd;
3493 long old_delta =
abs(best_pck - req_pck);
3494 long new_delta =
abs(pck - req_pck);
3496 if (best_pck == 0 || new_delta < old_delta) {
3509 if (lck / pcd_min < req_pck)
3529 cinfo->
lck = dispc_fclk_rate / cinfo->
lck_div;
3541 dispc_mgr_set_lcd_divisor(channel, cinfo->
lck_div, cinfo->
pck_div);
3561 static void _omap_dispc_set_irqs(
void)
3568 mask = dispc.irq_error_mask;
3571 isr_data = &dispc.registered_isr[
i];
3576 mask |= isr_data->
mask;
3590 unsigned long flags;
3600 isr_data = &dispc.registered_isr[
i];
3601 if (isr_data->
isr == isr && isr_data->
arg == arg &&
3602 isr_data->
mask == mask) {
3612 isr_data = &dispc.registered_isr[
i];
3628 _omap_dispc_set_irqs();
3630 spin_unlock_irqrestore(&dispc.irq_lock, flags);
3634 spin_unlock_irqrestore(&dispc.irq_lock, flags);
3643 unsigned long flags;
3650 isr_data = &dispc.registered_isr[
i];
3651 if (isr_data->
isr != isr || isr_data->
arg != arg ||
3652 isr_data->
mask != mask)
3666 _omap_dispc_set_irqs();
3668 spin_unlock_irqrestore(&dispc.irq_lock, flags);
3675 static void print_irq_status(
u32 status)
3677 if ((status & dispc.irq_error_mask) == 0)
3683 if (status & DISPC_IRQ_##x) \
3685 PIS(GFX_FIFO_UNDERFLOW);
3687 PIS(VID1_FIFO_UNDERFLOW);
3688 PIS(VID2_FIFO_UNDERFLOW);
3690 PIS(VID3_FIFO_UNDERFLOW);
3692 PIS(SYNC_LOST_DIGIT);
3710 u32 irqstatus, irqenable;
3711 u32 handledirqs = 0;
3712 u32 unhandled_errors;
3716 spin_lock(&dispc.irq_lock);
3722 if (!(irqstatus & irqenable)) {
3723 spin_unlock(&dispc.irq_lock);
3727 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
3728 spin_lock(&dispc.irq_stats_lock);
3729 dispc.irq_stats.irq_count++;
3730 dss_collect_irq_stats(irqstatus, dispc.irq_stats.irqs);
3731 spin_unlock(&dispc.irq_stats_lock);
3736 print_irq_status(irqstatus);
3749 spin_unlock(&dispc.irq_lock);
3757 if (isr_data->
mask & irqstatus) {
3758 isr_data->
isr(isr_data->
arg, irqstatus);
3759 handledirqs |= isr_data->
mask;
3763 spin_lock(&dispc.irq_lock);
3765 unhandled_errors = irqstatus & ~handledirqs & dispc.irq_error_mask;
3767 if (unhandled_errors) {
3768 dispc.error_irqs |= unhandled_errors;
3770 dispc.irq_error_mask &= ~unhandled_errors;
3771 _omap_dispc_set_irqs();
3776 spin_unlock(&dispc.irq_lock);
3785 unsigned long flags;
3786 static const unsigned fifo_underflow_bits[] = {
3794 errors = dispc.error_irqs;
3795 dispc.error_irqs = 0;
3796 spin_unlock_irqrestore(&dispc.irq_lock, flags);
3805 bit = fifo_underflow_bits[
i];
3808 DSSERR(
"FIFO UNDERFLOW on %s, disabling the overlay\n",
3821 bit = mgr_desc[
i].sync_lost_irq;
3827 DSSERR(
"SYNC_LOST on channel %s, restarting the output "
3828 "with video overlays disabled\n",
3832 dssdev->
driver->disable(dssdev);
3847 dssdev->
driver->enable(dssdev);
3860 if (dssdev && dssdev->
driver)
3861 dssdev->
driver->disable(dssdev);
3867 _omap_dispc_set_irqs();
3868 spin_unlock_irqrestore(&
dispc.irq_lock, flags);
3875 void dispc_irq_wait_handler(
void *
data,
u32 mask)
3903 unsigned long timeout)
3905 void dispc_irq_wait_handler(
void *
data,
u32 mask)
3933 static void _omap_dispc_initialize_irq(
void)
3935 unsigned long flags;
3953 _omap_dispc_set_irqs();
3955 spin_unlock_irqrestore(&
dispc.irq_lock, flags);
3968 static void _omap_dispc_initial_config(
void)
3985 dispc_setup_color_conv_coef();
3991 dispc_configure_burst_sizes();
3993 dispc_ovl_enable_zorder_planes();
4003 .calc_scaling = dispc_ovl_calc_scaling_24xx,
4004 .calc_core_clk = calc_core_clk_24xx,
4008 static const struct dispc_features omap34xx_rev1_0_dispc_feats __initconst = {
4015 .calc_scaling = dispc_ovl_calc_scaling_34xx,
4016 .calc_core_clk = calc_core_clk_34xx,
4020 static const struct dispc_features omap34xx_rev3_0_dispc_feats __initconst = {
4027 .calc_scaling = dispc_ovl_calc_scaling_34xx,
4028 .calc_core_clk = calc_core_clk_34xx,
4032 static const struct dispc_features omap44xx_dispc_feats __initconst = {
4039 .calc_scaling = dispc_ovl_calc_scaling_44xx,
4040 .calc_core_clk = calc_core_clk_44xx,
4042 .gfx_fifo_workaround =
true,
4052 dev_err(dev,
"Failed to allocate DISPC Features\n");
4057 src = &omap24xx_dispc_feats;
4060 src = &omap34xx_rev1_0_dispc_feats;
4062 src = &omap34xx_rev3_0_dispc_feats;
4064 src = &omap44xx_dispc_feats;
4066 src = &omap44xx_dispc_feats;
4071 memcpy(dst, src,
sizeof(*dst));
4087 r = dispc_init_features(&dispc.pdev->dev);
4093 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
4095 dispc.irq_stats.last_reset =
jiffies;
4098 INIT_WORK(&dispc.error_work, dispc_error_worker);
4102 DSSERR(
"can't get IORESOURCE_MEM DISPC\n");
4107 resource_size(dispc_mem));
4109 DSSERR(
"can't ioremap DISPC\n");
4114 if (dispc.irq < 0) {
4115 DSSERR(
"platform_get_irq failed\n");
4119 r = devm_request_irq(&pdev->
dev, dispc.irq, omap_dispc_irq_handler,
4122 DSSERR(
"request_irq failed\n");
4128 DSSERR(
"can't get fck\n");
4133 dispc.dss_clk = clk;
4139 goto err_runtime_get;
4141 _omap_dispc_initial_config();
4143 _omap_dispc_initialize_irq();
4146 dev_dbg(&pdev->
dev,
"OMAP DISPC rev %d.%d\n",
4153 #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
4159 pm_runtime_disable(&pdev->
dev);
4166 pm_runtime_disable(&pdev->
dev);
4173 static int dispc_runtime_suspend(
struct device *dev)
4175 dispc_save_context();
4180 static int dispc_runtime_resume(
struct device *dev)
4182 dispc_restore_context();
4187 static const struct dev_pm_ops dispc_pm_ops = {
4188 .runtime_suspend = dispc_runtime_suspend,
4189 .runtime_resume = dispc_runtime_resume,
4193 .remove =
__exit_p(omap_dispchw_remove),
4195 .name =
"omapdss_dispc",
4197 .pm = &dispc_pm_ops,