video: tegra: dc: Add new blender support
Mark Stadler [Thu, 2 Aug 2012 00:20:03 +0000 (17:20 -0700)]
Legacy blending modes are specified by the following flags:
 - TEGRA_WIN_FLAG_BLEND_COVERAGE -> source alpha blending
 - TEGRA_WIN_FLAG_BLEND_PREMULT -> pre-multiplied destination alpha
                                   blending
 - No flag -> no blending (opaque)

Change-Id: I3defeae842675cdc87199560a1f6061af9550568
Tested-by: Chao Xu <cxu@nvidia.com>
Reviewed-by: Mark Stadler <mastadler@nvidia.com>
Signed-off-by: Jin Qian <jqian@nvidia.com>
Reviewed-on: http://git-master/r/82943
Reviewed-by: Scott Williams <scwilliams@nvidia.com>
Signed-off-by: Mark Stadler <mastadler@nvidia.com>

drivers/video/tegra/dc/dc.c
drivers/video/tegra/dc/dc_reg.h
drivers/video/tegra/dc/hdmi.c

index 8d58084..5a3e227 100644 (file)
@@ -575,7 +575,9 @@ static void _dump_regs(struct tegra_dc *dc, void *data,
        DUMP_REG(DC_DISP_DATA_ENABLE_OPTIONS);
        DUMP_REG(DC_DISP_SERIAL_INTERFACE_OPTIONS);
        DUMP_REG(DC_DISP_LCD_SPI_OPTIONS);
+#if !defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
        DUMP_REG(DC_DISP_BORDER_COLOR);
+#endif
        DUMP_REG(DC_DISP_COLOR_KEY0_LOWER);
        DUMP_REG(DC_DISP_COLOR_KEY0_UPPER);
        DUMP_REG(DC_DISP_COLOR_KEY1_LOWER);
@@ -621,15 +623,15 @@ static void _dump_regs(struct tegra_dc *dc, void *data,
                DUMP_REG(DC_WIN_V_INITIAL_DDA);
                DUMP_REG(DC_WIN_DDA_INCREMENT);
                DUMP_REG(DC_WIN_LINE_STRIDE);
-#if defined(CONFIG_ARCH_TEGRA_2x_SOC) || defined(CONFIG_ARCH_TEGRA_3x_SOC)
+#if !defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
                DUMP_REG(DC_WIN_BUF_STRIDE);
                DUMP_REG(DC_WIN_UV_BUF_STRIDE);
-#endif
                DUMP_REG(DC_WIN_BLEND_NOKEY);
                DUMP_REG(DC_WIN_BLEND_1WIN);
                DUMP_REG(DC_WIN_BLEND_2WIN_X);
                DUMP_REG(DC_WIN_BLEND_2WIN_Y);
                DUMP_REG(DC_WIN_BLEND_3WIN_XY);
+#endif
                DUMP_REG(DC_WINBUF_START_ADDR);
                DUMP_REG(DC_WINBUF_START_ADDR_U);
                DUMP_REG(DC_WINBUF_START_ADDR_V);
@@ -1373,6 +1375,12 @@ static void tegra_dc_set_out(struct tegra_dc *dc, struct tegra_dc_out *out)
                dc->out_ops = &tegra_dc_dsi_ops;
                break;
 
+#ifdef CONFIG_TEGRA_DP
+       case TEGRA_DC_OUT_DP:
+               dc->out_ops = &tegra_dc_dp_ops;
+               break;
+#endif
+
        default:
                dc->out_ops = NULL;
                break;
@@ -2038,7 +2046,11 @@ static int tegra_dc_init(struct tegra_dc *dc)
        tegra_dc_writel(dc, ALL_UF_INT(), DC_CMD_INT_MASK);
        tegra_dc_init_vpulse2_int(dc);
 
+#if !defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
        tegra_dc_writel(dc, 0x00000000, DC_DISP_BORDER_COLOR);
+#else
+       tegra_dc_writel(dc, 0x00000000, DC_DISP_BLEND_BACKGROUND_COLOR);
+#endif
 
 #ifdef CONFIG_TEGRA_DC_CMU
        if (dc->pdata->cmu) {
index 5559ca8..5138135 100644 (file)
 
 #define DC_DISP_SERIAL_INTERFACE_OPTIONS       0x433
 #define DC_DISP_LCD_SPI_OPTIONS                        0x434
+
+#if !defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
+
 #define DC_DISP_BORDER_COLOR                   0x435
+
+#endif
+
 #define DC_DISP_COLOR_KEY0_LOWER               0x436
 #define DC_DISP_COLOR_KEY0_UPPER               0x437
 #define DC_DISP_COLOR_KEY1_LOWER               0x438
 #define  GET_LINE_STRIDE(x)    ((x) & 0xffff)
 #define  GET_UV_LINE_STRIDE(x) (((x) >> 16) & 0xffff)
 
+#if !defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
+
 #define DC_WINBUF_BLEND_LAYER_CONTROL          0x716
 #define  WIN_K1(x)                     (((x) & 0xff) << 8)
 #define  WIN_K2(x)                     (((x) & 0xff) << 16)
 #define  WIN_ALPHA_1BIT_WEIGHT0(x)     (((x) & 0xff) << 0)
 #define  WIN_ALPHA_1BIT_WEIGHT1(x)     (((x) & 0xff) << 8)
 
-#if defined(CONFIG_ARCH_TEGRA_2x_SOC) || defined(CONFIG_ARCH_TEGRA_3x_SOC)
 #define DC_WIN_BUF_STRIDE                      0x70b
 #define DC_WIN_UV_BUF_STRIDE                   0x70c
-#endif
 #define DC_WIN_BUFFER_ADDR_MODE                        0x70d
 #define  DC_WIN_BUFFER_ADDR_MODE_LINEAR                (0 << 0)
 #define  DC_WIN_BUFFER_ADDR_MODE_LINEAR_UV     (0 << 16)
 #define  DC_WIN_BUFFER_ADDR_MODE_TILE          (1 << 0)
 #define  DC_WIN_BUFFER_ADDR_MODE_TILE_UV       (1 << 16)
+
+#endif
+
 #define DC_WIN_DV_CONTROL                      0x70e
+
+#if !defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
+
 #define DC_WIN_BLEND_NOKEY                     0x70f
 #define DC_WIN_BLEND_1WIN                      0x710
 #define DC_WIN_BLEND_2WIN_X                    0x711
          (CKEY_ ## key | BLEND_CONTROL_ ## control |           \
           BLEND_WEIGHT0(weight0) | BLEND_WEIGHT1(weight1))
 
+#endif
+
 
 #define DC_WIN_HP_FETCH_CONTROL                        0x714
 
 #define DC_WINBUF_TD_UFLOW_STATUS              0x14a
 #endif
 
+#if defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
+
+#define DC_WINBUF_BLEND_LAYER_CONTROL          0x824
+#define  WIN_DEPTH(x)                  (((x) & 0xff) << 0)
+#define  WIN_K1(x)                     (((x) & 0xff) << 8)
+#define  WIN_K2(x)                     (((x) & 0xff) << 16)
+#define  WIN_BLEND_ENABLE              (0 << 24)
+#define  WIN_BLEND_BYPASS              (1 << 24)
+#define  WIN_CKEY_SEL_NONE             (0 << 25)
+#define  WIN_CKEY_SEL_WINA_KEY0                (1 << 25)
+#define  WIN_CKEY_SEL_WINA_KEY1                (2 << 25)
+#define  WIN_CKEY_SEL_WINB_KEY0                (3 << 25)
+#define  WIN_CKEY_SEL_WINB_KEY1                (4 << 25)
+#define  WIN_CKEY_SEL_WINC_KEY0                (5 << 25)
+#define  WIN_CKEY_SEL_WINC_KEY1                (6 << 25)
+
+#define DC_WINBUF_BLEND_MATCH_SELECT           0x825
+#define  WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_ZERO \
+                                       (0 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1 \
+                                       (1 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1_TIMES_DST \
+                                       (2 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_NEG_K1_TIMES_DST \
+                                       (3 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_MATCH_SEL_K1_TIMES_SRC \
+                                       (4 << 0)
+#define  WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_ZERO \
+                                       (0 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_ONE \
+                                       (1 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_K1 \
+                                       (2 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_K2 \
+                                       (3 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_K1_TIMES_DST \
+                                       (4 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_NEG_K1_TIMES_DST \
+                                       (5 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_MATCH_SEL_NEG_K1_TIMES_SRC \
+                                       (6 << 4)
+#define  WIN_BLEND_FACT_SRC_ALPHA_MATCH_SEL_ZERO \
+                                       (0 << 8)
+#define  WIN_BLEND_FACT_SRC_ALPHA_MATCH_SEL_K1 \
+                                       (1 << 8)
+#define  WIN_BLEND_FACT_SRC_ALPHA_MATCH_SEL_K2 \
+                                       (2 << 8)
+#define  WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_ZERO \
+                                       (0 << 12)
+#define  WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_ONE \
+                                       (1 << 12)
+#define  WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_NEG_K1_TIMES_SRC \
+                                       (2 << 12)
+#define  WIN_BLEND_FACT_DST_ALPHA_MATCH_SEL_K2 \
+                                       (3 << 12)
+
+#define DC_WINBUF_BLEND_NOMATCH_SELECT         0x826
+#define  WIN_BLEND_FACT_SRC_COLOR_NOMATCH_SEL_ZERO \
+                                       (0 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_NOMATCH_SEL_K1 \
+                                       (1 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_NOMATCH_SEL_K1_TIMES_DST \
+                                       (2 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_NOMATCH_SEL_NEG_K1_TIMES_DST \
+                                       (3 << 0)
+#define  WIN_BLEND_FACT_SRC_COLOR_NOMATCH_SEL_K1_TIMES_SRC \
+                                       (4 << 0)
+#define  WIN_BLEND_FACT_DST_COLOR_NOMATCH_SEL_ZERO \
+                                       (0 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_NOMATCH_SEL_ONE \
+                                       (1 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_NOMATCH_SEL_K1 \
+                                       (2 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_NOMATCH_SEL_K2 \
+                                       (3 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_NOMATCH_SEL_K1_TIMES_DST \
+                                       (4 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_NOMATCH_SEL_NEG_K1_TIMES_DST \
+                                       (5 << 4)
+#define  WIN_BLEND_FACT_DST_COLOR_NOMATCH_SEL_NEG_K1_TIMES_SRC \
+                                       (6 << 4)
+#define  WIN_BLEND_FACT_SRC_ALPHA_NOMATCH_SEL_ZERO \
+                                       (0 << 8)
+#define  WIN_BLEND_FACT_SRC_ALPHA_NOMATCH_SEL_K1 \
+                                       (1 << 8)
+#define  WIN_BLEND_FACT_SRC_ALPHA_NOMATCH_SEL_K2 \
+                                       (2 << 8)
+#define  WIN_BLEND_FACT_DST_ALPHA_NOMATCH_SEL_ZERO \
+                                       (0 << 12)
+#define  WIN_BLEND_FACT_DST_ALPHA_NOMATCH_SEL_ONE \
+                                       (1 << 12)
+#define  WIN_BLEND_FACT_DST_ALPHA_NOMATCH_SEL_NEG_K1_TIMES_SRC \
+                                       (2 << 12)
+#define  WIN_BLEND_FACT_DST_ALPHA_NOMATCH_SEL_K2 \
+                                       (3 << 12)
+
+#define DC_WINBUF_BLEND_ALPHA_1BIT             0x827
+#define  WIN_ALPHA_1BIT_WEIGHT0(x)     (((x) & 0xff) << 0)
+#define  WIN_ALPHA_1BIT_WEIGHT1(x)     (((x) & 0xff) << 8)
+
+#endif
+
 #define DC_DISP_SD_CONTROL                     0x4c2
 #define  SD_ENABLE_NORMAL              (1 << 0)
 #define  SD_ENABLE_ONESHOT             (2 << 0)
 #define  WINH_CURS_SELECT(x)           (((x) & 0x1) << 28)
 #define  CURSOR_MODE_SELECT(x)         (((x) & 0x1) << 24)
 
+#if defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
+
+#define DC_DISP_BLEND_BACKGROUND_COLOR         0x4e4
+
+#endif
+
 #endif
index cbe0286..8b278a2 100644 (file)
@@ -1637,6 +1637,7 @@ static void tegra_dc_hdmi_setup_avi_infoframe(struct tegra_dc *dc, bool dvi)
 {
        struct tegra_dc_hdmi_data *hdmi = tegra_dc_get_outdata(dc);
        struct hdmi_avi_infoframe avi;
+       unsigned int blender_reg;
 
        if (dvi) {
                tegra_hdmi_writel(hdmi, 0x0,
@@ -1650,10 +1651,16 @@ static void tegra_dc_hdmi_setup_avi_infoframe(struct tegra_dc *dc, bool dvi)
        avi.a = 1;
        avi.r = HDMI_AVI_R_SAME;
 
+#if !defined(CONFIG_TEGRA_DC_BLENDER_GEN2)
+       blender_reg = DC_DISP_BORDER_COLOR;
+#else
+       blender_reg = DC_DISP_BLEND_BACKGROUND_COLOR;
+#endif
+
        if ((dc->mode.h_active == 720) && ((dc->mode.v_active == 480) || (dc->mode.v_active == 576)))
-               tegra_dc_writel(dc, 0x00101010, DC_DISP_BORDER_COLOR);
+               tegra_dc_writel(dc, 0x00101010, blender_reg);
        else
-               tegra_dc_writel(dc, 0x00000000, DC_DISP_BORDER_COLOR);
+               tegra_dc_writel(dc, 0x00000000, blender_reg);
 
        avi.vic = tegra_dc_find_cea_vic(&dc->mode);
        avi.m = dc->mode.avi_m;