Lines Matching defs:ast

3  * Parts based on xf86-video-ast
54 static inline void ast_load_palette_index(struct ast_device *ast,
58 ast_io_write8(ast, AST_IO_VGADWR, index);
59 ast_io_read8(ast, AST_IO_VGASRI);
60 ast_io_write8(ast, AST_IO_VGAPDR, red);
61 ast_io_read8(ast, AST_IO_VGASRI);
62 ast_io_write8(ast, AST_IO_VGAPDR, green);
63 ast_io_read8(ast, AST_IO_VGASRI);
64 ast_io_write8(ast, AST_IO_VGAPDR, blue);
65 ast_io_read8(ast, AST_IO_VGASRI);
68 static void ast_crtc_set_gamma_linear(struct ast_device *ast,
78 ast_load_palette_index(ast, i, i, i, i);
81 drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n",
87 static void ast_crtc_set_gamma(struct ast_device *ast,
98 ast_load_palette_index(ast, i,
104 drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n",
235 static void ast_set_vbios_color_reg(struct ast_device *ast,
256 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8c, (u8)((color_index & 0x0f) << 4));
258 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0x00);
261 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0xa8);
262 ast_set_index_reg(ast, AST_IO_VGACRI, 0x92, format->cpp[0] * 8);
266 static void ast_set_vbios_mode_reg(struct ast_device *ast,
275 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8d, refresh_rate_index & 0xff);
276 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8e, mode_id & 0xff);
278 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0x00);
281 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0xa8);
282 ast_set_index_reg(ast, AST_IO_VGACRI, 0x93, adjusted_mode->clock / 1000);
283 ast_set_index_reg(ast, AST_IO_VGACRI, 0x94, adjusted_mode->crtc_hdisplay);
284 ast_set_index_reg(ast, AST_IO_VGACRI, 0x95, adjusted_mode->crtc_hdisplay >> 8);
285 ast_set_index_reg(ast, AST_IO_VGACRI, 0x96, adjusted_mode->crtc_vdisplay);
286 ast_set_index_reg(ast, AST_IO_VGACRI, 0x97, adjusted_mode->crtc_vdisplay >> 8);
290 static void ast_set_std_reg(struct ast_device *ast,
301 ast_io_write8(ast, AST_IO_VGAMR_W, jreg);
304 ast_set_index_reg(ast, AST_IO_VGASRI, 0x00, 0x03);
305 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, stdtable->seq[0]);
308 ast_set_index_reg(ast, AST_IO_VGASRI, (i + 1), jreg);
312 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00);
314 ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]);
316 ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]);
318 ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]);
321 jreg = ast_io_read8(ast, AST_IO_VGAIR1_R);
324 ast_io_write8(ast, AST_IO_VGAARI_W, (u8)i);
325 ast_io_write8(ast, AST_IO_VGAARI_W, jreg);
327 ast_io_write8(ast, AST_IO_VGAARI_W, 0x14);
328 ast_io_write8(ast, AST_IO_VGAARI_W, 0x00);
330 jreg = ast_io_read8(ast, AST_IO_VGAIR1_R);
331 ast_io_write8(ast, AST_IO_VGAARI_W, 0x20);
335 ast_set_index_reg(ast, AST_IO_VGAGRI, i, stdtable->gr[i]);
338 static void ast_set_crtc_reg(struct ast_device *ast,
345 if ((IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) &&
349 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00);
354 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x00, 0x00, temp);
359 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x01, 0x00, temp);
364 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x02, 0x00, temp);
371 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x03, 0xE0, (temp & 0x1f));
376 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x04, 0x00, temp);
381 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x05, 0x60, (u8)((temp & 0x1f) | jreg05));
383 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAC, 0x00, jregAC);
384 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAD, 0x00, jregAD);
387 if (IS_AST_GEN7(ast) && (mode->crtc_vdisplay == 1080))
388 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xFC, 0xFD, 0x02);
390 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xFC, 0xFD, 0x00);
400 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x06, 0x00, temp);
409 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x10, 0x00, temp);
416 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x70, temp & 0xf);
425 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x12, 0x00, temp);
434 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x15, 0x00, temp);
439 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x16, 0x00, temp);
441 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x07, 0x00, jreg07);
442 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x09, 0xdf, jreg09);
443 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAE, 0x00, (jregAE | 0x80));
446 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x80);
448 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x00);
450 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x80);
453 static void ast_set_offset_reg(struct ast_device *ast,
459 ast_set_index_reg(ast, AST_IO_VGACRI, 0x13, (offset & 0xff));
460 ast_set_index_reg(ast, AST_IO_VGACRI, 0xb0, (offset >> 8) & 0x3f);
463 static void ast_set_dclk_reg(struct ast_device *ast,
469 if (IS_AST_GEN6(ast) || IS_AST_GEN7(ast))
474 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xc0, 0x00, clk_info->param1);
475 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xc1, 0x00, clk_info->param2);
476 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xbb, 0x0f,
481 static void ast_set_color_reg(struct ast_device *ast,
505 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa0, 0x8f, jregA0);
506 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa3, 0xf0, jregA3);
507 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa8, 0xfd, jregA8);
510 static void ast_set_crtthd_reg(struct ast_device *ast)
513 if (IS_AST_GEN7(ast)) {
514 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0xe0);
515 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0xa0);
516 } else if (IS_AST_GEN6(ast) || IS_AST_GEN5(ast) || IS_AST_GEN4(ast)) {
517 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x78);
518 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x60);
519 } else if (IS_AST_GEN3(ast) || IS_AST_GEN2(ast)) {
520 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x3f);
521 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x2f);
523 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x2f);
524 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x1f);
528 static void ast_set_sync_reg(struct ast_device *ast,
534 jreg = ast_io_read8(ast, AST_IO_VGAMR_R);
540 ast_io_write8(ast, AST_IO_VGAMR_W, jreg);
543 static void ast_set_start_address_crt1(struct ast_device *ast,
549 ast_set_index_reg(ast, AST_IO_VGACRI, 0x0d, (u8)(addr & 0xff));
550 ast_set_index_reg(ast, AST_IO_VGACRI, 0x0c, (u8)((addr >> 8) & 0xff));
551 ast_set_index_reg(ast, AST_IO_VGACRI, 0xaf, (u8)((addr >> 16) & 0xff));
555 static void ast_wait_for_vretrace(struct ast_device *ast)
561 vgair1 = ast_io_read8(ast, AST_IO_VGAIR1_R);
644 struct ast_device *ast = to_ast_device(dev);
660 ast_set_color_reg(ast, fb->format);
661 ast_set_vbios_color_reg(ast, fb->format, vbios_mode_info);
676 ast_set_offset_reg(ast, fb);
682 struct ast_device *ast = to_ast_device(plane->dev);
691 ast_set_start_address_crt1(ast, (u32)ast_plane->offset);
692 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x1, 0xdf, 0x00);
698 struct ast_device *ast = to_ast_device(plane->dev);
700 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x1, 0xdf, 0x20);
718 static int ast_primary_plane_init(struct ast_device *ast)
720 struct drm_device *dev = &ast->base;
721 struct ast_plane *ast_primary_plane = &ast->primary_plane;
723 void __iomem *vaddr = ast->vram;
726 unsigned long size = ast->vram_fb_available - cursor_size;
811 static void ast_set_cursor_base(struct ast_device *ast, u64 address)
817 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc8, addr0);
818 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc9, addr1);
819 ast_set_index_reg(ast, AST_IO_VGACRI, 0xca, addr2);
822 static void ast_set_cursor_location(struct ast_device *ast, u16 x, u16 y,
830 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc2, x_offset);
831 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc3, y_offset);
832 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc4, x0);
833 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc5, x1);
834 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc6, y0);
835 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc7, y1);
838 static void ast_set_cursor_enabled(struct ast_device *ast, bool enabled)
848 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xcb, mask, vgacrcb);
887 struct ast_device *ast = to_ast_device(plane->dev);
905 ast_set_cursor_base(ast, dst_off);
933 ast_set_cursor_location(ast, x, y, x_offset, y_offset);
936 ast_set_cursor_enabled(ast, true);
942 struct ast_device *ast = to_ast_device(plane->dev);
944 ast_set_cursor_enabled(ast, false);
961 static int ast_cursor_plane_init(struct ast_device *ast)
963 struct drm_device *dev = &ast->base;
964 struct ast_plane *ast_cursor_plane = &ast->cursor_plane;
978 if (ast->vram_fb_available < size)
981 vaddr = ast->vram + ast->vram_fb_available - size;
982 offset = ast->vram_fb_available - size;
995 ast->vram_fb_available -= size;
1006 struct ast_device *ast = to_ast_device(crtc->dev);
1017 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, 0);
1018 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xfc, 0);
1019 if (ast->tx_chip_types & AST_TX_DP501_BIT)
1022 if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
1024 ast_wait_for_vretrace(ast);
1034 ast_set_color_reg(ast, format);
1035 ast_set_vbios_color_reg(ast, format, vbios_mode_info);
1037 ast_crtc_set_gamma(ast, format, crtc->state->gamma_lut->data);
1039 ast_crtc_set_gamma_linear(ast, format);
1046 if (ast->tx_chip_types & AST_TX_DP501_BIT)
1049 if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
1054 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, 0x20);
1055 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xfc, ch);
1063 struct ast_device *ast = to_ast_device(crtc->dev);
1067 if (ast->support_wide_screen) {
1081 if ((ast->chip == AST2100) || // GEN2, but not AST1100 (?)
1082 (ast->chip == AST2200) || // GEN3, but not AST2150 (?)
1083 IS_AST_GEN4(ast) || IS_AST_GEN5(ast) ||
1084 IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) {
1089 jtemp = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xd1, 0xff);
1189 struct ast_device *ast = to_ast_device(dev);
1199 ast_crtc_set_gamma(ast,
1203 ast_crtc_set_gamma_linear(ast, ast_crtc_state->format);
1207 if (ast->tx_chip_types & AST_TX_ASTDP_BIT)
1214 struct ast_device *ast = to_ast_device(dev);
1221 ast_set_vbios_mode_reg(ast, adjusted_mode, vbios_mode_info);
1222 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa1, 0x06);
1223 ast_set_std_reg(ast, adjusted_mode, vbios_mode_info);
1224 ast_set_crtc_reg(ast, adjusted_mode, vbios_mode_info);
1225 ast_set_dclk_reg(ast, adjusted_mode, vbios_mode_info);
1226 ast_set_crtthd_reg(ast);
1227 ast_set_sync_reg(ast, adjusted_mode, vbios_mode_info);
1236 struct ast_device *ast = to_ast_device(dev);
1256 ast_wait_for_vretrace(ast);
1324 struct ast_device *ast = to_ast_device(dev);
1325 struct drm_crtc *crtc = &ast->crtc;
1328 ret = drm_crtc_init_with_planes(dev, crtc, &ast->primary_plane.base,
1329 &ast->cursor_plane.base, &ast_crtc_funcs,
1350 struct ast_device *ast = to_ast_device(dev);
1361 mutex_lock(&ast->modeset_lock);
1367 mutex_unlock(&ast->modeset_lock);
1375 mutex_unlock(&ast->modeset_lock);
1423 static int ast_vga_output_init(struct ast_device *ast)
1425 struct drm_device *dev = &ast->base;
1426 struct drm_crtc *crtc = &ast->crtc;
1427 struct drm_encoder *encoder = &ast->output.vga.encoder;
1428 struct ast_vga_connector *ast_vga_connector = &ast->output.vga.vga_connector;
1456 struct ast_device *ast = to_ast_device(dev);
1467 mutex_lock(&ast->modeset_lock);
1473 mutex_unlock(&ast->modeset_lock);
1481 mutex_unlock(&ast->modeset_lock);
1529 static int ast_sil164_output_init(struct ast_device *ast)
1531 struct drm_device *dev = &ast->base;
1532 struct drm_crtc *crtc = &ast->crtc;
1533 struct drm_encoder *encoder = &ast->output.sil164.encoder;
1534 struct ast_sil164_connector *ast_sil164_connector = &ast->output.sil164.sil164_connector;
1589 struct ast_device *ast = to_ast_device(connector->dev);
1591 if (ast_dp501_is_connected(ast))
1628 static int ast_dp501_output_init(struct ast_device *ast)
1630 struct drm_device *dev = &ast->base;
1631 struct drm_crtc *crtc = &ast->crtc;
1632 struct drm_encoder *encoder = &ast->output.dp501.encoder;
1633 struct drm_connector *connector = &ast->output.dp501.connector;
1660 struct ast_device *ast = to_ast_device(dev);
1673 mutex_lock(&ast->modeset_lock);
1679 mutex_unlock(&ast->modeset_lock);
1688 mutex_unlock(&ast->modeset_lock);
1699 struct ast_device *ast = to_ast_device(connector->dev);
1701 if (ast_astdp_is_connected(ast))
1738 static int ast_astdp_output_init(struct ast_device *ast)
1740 struct drm_device *dev = &ast->base;
1741 struct drm_crtc *crtc = &ast->crtc;
1742 struct drm_encoder *encoder = &ast->output.astdp.encoder;
1743 struct drm_connector *connector = &ast->output.astdp.connector;
1831 static int ast_bmc_output_init(struct ast_device *ast,
1834 struct drm_device *dev = &ast->base;
1835 struct drm_crtc *crtc = &ast->crtc;
1836 struct drm_encoder *encoder = &ast->output.bmc.encoder;
1837 struct ast_bmc_connector *bmc_connector = &ast->output.bmc.bmc_connector;
1865 struct ast_device *ast = to_ast_device(state->dev);
1873 mutex_lock(&ast->modeset_lock);
1875 mutex_unlock(&ast->modeset_lock);
1886 struct ast_device *ast = to_ast_device(dev);
1889 max_fbpages = (ast->vram_fb_available) >> PAGE_SHIFT;
1907 int ast_mode_config_init(struct ast_device *ast)
1909 struct drm_device *dev = &ast->base;
1913 ret = drmm_mutex_init(dev, &ast->modeset_lock);
1926 if (ast->chip == AST2100 || // GEN2, but not AST1100 (?)
1927 ast->chip == AST2200 || // GEN3, but not AST2150 (?)
1928 IS_AST_GEN7(ast) ||
1929 IS_AST_GEN6(ast) ||
1930 IS_AST_GEN5(ast) ||
1931 IS_AST_GEN4(ast)) {
1941 ret = ast_primary_plane_init(ast);
1945 ret = ast_cursor_plane_init(ast);
1951 if (ast->tx_chip_types & AST_TX_NONE_BIT) {
1952 ret = ast_vga_output_init(ast);
1955 physical_connector = &ast->output.vga.vga_connector.base;
1957 if (ast->tx_chip_types & AST_TX_SIL164_BIT) {
1958 ret = ast_sil164_output_init(ast);
1961 physical_connector = &ast->output.sil164.sil164_connector.base;
1963 if (ast->tx_chip_types & AST_TX_DP501_BIT) {
1964 ret = ast_dp501_output_init(ast);
1967 physical_connector = &ast->output.dp501.connector;
1969 if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
1970 ret = ast_astdp_output_init(ast);
1973 physical_connector = &ast->output.astdp.connector;
1975 ret = ast_bmc_output_init(ast, physical_connector);