Lines Matching refs:ast

3  * Parts based on xf86-video-ast
56 static inline void ast_load_palette_index(struct ast_device *ast,
60 ast_io_write8(ast, AST_IO_VGADWR, index);
61 ast_io_read8(ast, AST_IO_VGASRI);
62 ast_io_write8(ast, AST_IO_VGAPDR, red);
63 ast_io_read8(ast, AST_IO_VGASRI);
64 ast_io_write8(ast, AST_IO_VGAPDR, green);
65 ast_io_read8(ast, AST_IO_VGASRI);
66 ast_io_write8(ast, AST_IO_VGAPDR, blue);
67 ast_io_read8(ast, AST_IO_VGASRI);
70 static void ast_crtc_set_gamma_linear(struct ast_device *ast,
80 ast_load_palette_index(ast, i, i, i, i);
83 drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n",
89 static void ast_crtc_set_gamma(struct ast_device *ast,
100 ast_load_palette_index(ast, i,
106 drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n",
237 static void ast_set_vbios_color_reg(struct ast_device *ast,
258 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8c, (u8)((color_index & 0x0f) << 4));
260 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0x00);
263 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0xa8);
264 ast_set_index_reg(ast, AST_IO_VGACRI, 0x92, format->cpp[0] * 8);
268 static void ast_set_vbios_mode_reg(struct ast_device *ast,
277 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8d, refresh_rate_index & 0xff);
278 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8e, mode_id & 0xff);
280 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0x00);
283 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0xa8);
284 ast_set_index_reg(ast, AST_IO_VGACRI, 0x93, adjusted_mode->clock / 1000);
285 ast_set_index_reg(ast, AST_IO_VGACRI, 0x94, adjusted_mode->crtc_hdisplay);
286 ast_set_index_reg(ast, AST_IO_VGACRI, 0x95, adjusted_mode->crtc_hdisplay >> 8);
287 ast_set_index_reg(ast, AST_IO_VGACRI, 0x96, adjusted_mode->crtc_vdisplay);
288 ast_set_index_reg(ast, AST_IO_VGACRI, 0x97, adjusted_mode->crtc_vdisplay >> 8);
292 static void ast_set_std_reg(struct ast_device *ast,
303 ast_io_write8(ast, AST_IO_VGAMR_W, jreg);
306 ast_set_index_reg(ast, AST_IO_VGASRI, 0x00, 0x03);
307 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, stdtable->seq[0]);
310 ast_set_index_reg(ast, AST_IO_VGASRI, (i + 1), jreg);
314 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00);
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]);
320 ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]);
323 jreg = ast_io_read8(ast, AST_IO_VGAIR1_R);
326 ast_io_write8(ast, AST_IO_VGAARI_W, (u8)i);
327 ast_io_write8(ast, AST_IO_VGAARI_W, jreg);
329 ast_io_write8(ast, AST_IO_VGAARI_W, 0x14);
330 ast_io_write8(ast, AST_IO_VGAARI_W, 0x00);
332 jreg = ast_io_read8(ast, AST_IO_VGAIR1_R);
333 ast_io_write8(ast, AST_IO_VGAARI_W, 0x20);
337 ast_set_index_reg(ast, AST_IO_VGAGRI, i, stdtable->gr[i]);
340 static void ast_set_crtc_reg(struct ast_device *ast,
347 if ((IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) &&
351 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00);
356 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x00, 0x00, temp);
361 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x01, 0x00, temp);
366 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x02, 0x00, temp);
373 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x03, 0xE0, (temp & 0x1f));
378 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x04, 0x00, temp);
383 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x05, 0x60, (u8)((temp & 0x1f) | jreg05));
385 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAC, 0x00, jregAC);
386 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAD, 0x00, jregAD);
389 if (IS_AST_GEN7(ast) && (mode->crtc_vdisplay == 1080))
390 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xFC, 0xFD, 0x02);
392 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xFC, 0xFD, 0x00);
402 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x06, 0x00, temp);
411 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x10, 0x00, temp);
418 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x70, temp & 0xf);
427 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x12, 0x00, temp);
436 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x15, 0x00, temp);
441 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x16, 0x00, temp);
443 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x07, 0x00, jreg07);
444 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x09, 0xdf, jreg09);
445 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAE, 0x00, (jregAE | 0x80));
448 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x80);
450 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x00);
452 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x80);
455 static void ast_set_offset_reg(struct ast_device *ast,
461 ast_set_index_reg(ast, AST_IO_VGACRI, 0x13, (offset & 0xff));
462 ast_set_index_reg(ast, AST_IO_VGACRI, 0xb0, (offset >> 8) & 0x3f);
465 static void ast_set_dclk_reg(struct ast_device *ast,
471 if (IS_AST_GEN6(ast) || IS_AST_GEN7(ast))
476 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xc0, 0x00, clk_info->param1);
477 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xc1, 0x00, clk_info->param2);
478 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xbb, 0x0f,
483 static void ast_set_color_reg(struct ast_device *ast,
507 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa0, 0x8f, jregA0);
508 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa3, 0xf0, jregA3);
509 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa8, 0xfd, jregA8);
512 static void ast_set_crtthd_reg(struct ast_device *ast)
515 if (IS_AST_GEN7(ast)) {
516 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0xe0);
517 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0xa0);
518 } else if (IS_AST_GEN6(ast) || IS_AST_GEN5(ast) || IS_AST_GEN4(ast)) {
519 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x78);
520 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x60);
521 } else if (IS_AST_GEN3(ast) || IS_AST_GEN2(ast)) {
522 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x3f);
523 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x2f);
525 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x2f);
526 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x1f);
530 static void ast_set_sync_reg(struct ast_device *ast,
536 jreg = ast_io_read8(ast, AST_IO_VGAMR_R);
542 ast_io_write8(ast, AST_IO_VGAMR_W, jreg);
545 static void ast_set_start_address_crt1(struct ast_device *ast,
551 ast_set_index_reg(ast, AST_IO_VGACRI, 0x0d, (u8)(addr & 0xff));
552 ast_set_index_reg(ast, AST_IO_VGACRI, 0x0c, (u8)((addr >> 8) & 0xff));
553 ast_set_index_reg(ast, AST_IO_VGACRI, 0xaf, (u8)((addr >> 16) & 0xff));
557 static void ast_wait_for_vretrace(struct ast_device *ast)
563 vgair1 = ast_io_read8(ast, AST_IO_VGAIR1_R);
646 struct ast_device *ast = to_ast_device(dev);
662 ast_set_color_reg(ast, fb->format);
663 ast_set_vbios_color_reg(ast, fb->format, vbios_mode_info);
678 ast_set_offset_reg(ast, fb);
684 struct ast_device *ast = to_ast_device(plane->dev);
693 ast_set_start_address_crt1(ast, (u32)ast_plane->offset);
694 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x1, 0xdf, 0x00);
700 struct ast_device *ast = to_ast_device(plane->dev);
702 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x1, 0xdf, 0x20);
737 static int ast_primary_plane_init(struct ast_device *ast)
739 struct drm_device *dev = &ast->base;
740 struct ast_plane *ast_primary_plane = &ast->primary_plane;
742 void __iomem *vaddr = ast->vram;
745 unsigned long size = ast->vram_fb_available - cursor_size;
830 static void ast_set_cursor_base(struct ast_device *ast, u64 address)
836 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc8, addr0);
837 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc9, addr1);
838 ast_set_index_reg(ast, AST_IO_VGACRI, 0xca, addr2);
841 static void ast_set_cursor_location(struct ast_device *ast, u16 x, u16 y,
849 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc2, x_offset);
850 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc3, y_offset);
851 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc4, x0);
852 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc5, x1);
853 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc6, y0);
854 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc7, y1);
857 static void ast_set_cursor_enabled(struct ast_device *ast, bool enabled)
867 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xcb, mask, vgacrcb);
906 struct ast_device *ast = to_ast_device(plane->dev);
924 ast_set_cursor_base(ast, dst_off);
952 ast_set_cursor_location(ast, x, y, x_offset, y_offset);
955 ast_set_cursor_enabled(ast, true);
961 struct ast_device *ast = to_ast_device(plane->dev);
963 ast_set_cursor_enabled(ast, false);
980 static int ast_cursor_plane_init(struct ast_device *ast)
982 struct drm_device *dev = &ast->base;
983 struct ast_plane *ast_cursor_plane = &ast->cursor_plane;
997 if (ast->vram_fb_available < size)
1000 vaddr = ast->vram + ast->vram_fb_available - size;
1001 offset = ast->vram_fb_available - size;
1014 ast->vram_fb_available -= size;
1025 struct ast_device *ast = to_ast_device(crtc->dev);
1036 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, 0);
1037 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xfc, 0);
1038 if (ast->tx_chip_types & AST_TX_DP501_BIT)
1041 if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
1043 ast_wait_for_vretrace(ast);
1053 ast_set_color_reg(ast, format);
1054 ast_set_vbios_color_reg(ast, format, vbios_mode_info);
1056 ast_crtc_set_gamma(ast, format, crtc->state->gamma_lut->data);
1058 ast_crtc_set_gamma_linear(ast, format);
1065 if (ast->tx_chip_types & AST_TX_DP501_BIT)
1068 if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
1073 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, 0x20);
1074 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xfc, ch);
1082 struct ast_device *ast = to_ast_device(crtc->dev);
1086 if (ast->support_wide_screen) {
1100 if ((ast->chip == AST2100) || // GEN2, but not AST1100 (?)
1101 (ast->chip == AST2200) || // GEN3, but not AST2150 (?)
1102 IS_AST_GEN4(ast) || IS_AST_GEN5(ast) ||
1103 IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) {
1108 jtemp = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xd1, 0xff);
1208 struct ast_device *ast = to_ast_device(dev);
1218 ast_crtc_set_gamma(ast,
1222 ast_crtc_set_gamma_linear(ast, ast_crtc_state->format);
1226 if (ast->tx_chip_types & AST_TX_ASTDP_BIT)
1233 struct ast_device *ast = to_ast_device(dev);
1240 ast_set_vbios_mode_reg(ast, adjusted_mode, vbios_mode_info);
1241 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa1, 0x06);
1242 ast_set_std_reg(ast, adjusted_mode, vbios_mode_info);
1243 ast_set_crtc_reg(ast, adjusted_mode, vbios_mode_info);
1244 ast_set_dclk_reg(ast, adjusted_mode, vbios_mode_info);
1245 ast_set_crtthd_reg(ast);
1246 ast_set_sync_reg(ast, adjusted_mode, vbios_mode_info);
1255 struct ast_device *ast = to_ast_device(dev);
1275 ast_wait_for_vretrace(ast);
1343 struct ast_device *ast = to_ast_device(dev);
1344 struct drm_crtc *crtc = &ast->crtc;
1347 ret = drm_crtc_init_with_planes(dev, crtc, &ast->primary_plane.base,
1348 &ast->cursor_plane.base, &ast_crtc_funcs,
1380 struct ast_device *ast = to_ast_device(dev);
1384 ddc = ast_ddc_create(ast);
1406 static int ast_vga_output_init(struct ast_device *ast)
1408 struct drm_device *dev = &ast->base;
1409 struct drm_crtc *crtc = &ast->crtc;
1410 struct drm_encoder *encoder = &ast->output.vga.encoder;
1411 struct drm_connector *connector = &ast->output.vga.connector;
1449 struct ast_device *ast = to_ast_device(dev);
1453 ddc = ast_ddc_create(ast);
1475 static int ast_sil164_output_init(struct ast_device *ast)
1477 struct drm_device *dev = &ast->base;
1478 struct drm_crtc *crtc = &ast->crtc;
1479 struct drm_encoder *encoder = &ast->output.sil164.encoder;
1480 struct drm_connector *connector = &ast->output.sil164.connector;
1534 struct ast_device *ast = to_ast_device(connector->dev);
1536 if (ast_dp501_is_connected(ast))
1573 static int ast_dp501_output_init(struct ast_device *ast)
1575 struct drm_device *dev = &ast->base;
1576 struct drm_crtc *crtc = &ast->crtc;
1577 struct drm_encoder *encoder = &ast->output.dp501.encoder;
1578 struct drm_connector *connector = &ast->output.dp501.connector;
1605 struct ast_device *ast = to_ast_device(dev);
1618 mutex_lock(&ast->modeset_lock);
1624 mutex_unlock(&ast->modeset_lock);
1633 mutex_unlock(&ast->modeset_lock);
1644 struct ast_device *ast = to_ast_device(connector->dev);
1646 if (ast_astdp_is_connected(ast))
1683 static int ast_astdp_output_init(struct ast_device *ast)
1685 struct drm_device *dev = &ast->base;
1686 struct drm_crtc *crtc = &ast->crtc;
1687 struct drm_encoder *encoder = &ast->output.astdp.encoder;
1688 struct drm_connector *connector = &ast->output.astdp.connector;
1776 static int ast_bmc_output_init(struct ast_device *ast,
1779 struct drm_device *dev = &ast->base;
1780 struct drm_crtc *crtc = &ast->crtc;
1781 struct drm_encoder *encoder = &ast->output.bmc.encoder;
1782 struct ast_bmc_connector *bmc_connector = &ast->output.bmc.bmc_connector;
1810 struct ast_device *ast = to_ast_device(state->dev);
1818 mutex_lock(&ast->modeset_lock);
1820 mutex_unlock(&ast->modeset_lock);
1831 struct ast_device *ast = to_ast_device(dev);
1834 max_fbpages = (ast->vram_fb_available) >> PAGE_SHIFT;
1852 int ast_mode_config_init(struct ast_device *ast)
1854 struct drm_device *dev = &ast->base;
1858 ret = drmm_mutex_init(dev, &ast->modeset_lock);
1871 if (ast->chip == AST2100 || // GEN2, but not AST1100 (?)
1872 ast->chip == AST2200 || // GEN3, but not AST2150 (?)
1873 IS_AST_GEN7(ast) ||
1874 IS_AST_GEN6(ast) ||
1875 IS_AST_GEN5(ast) ||
1876 IS_AST_GEN4(ast)) {
1886 ret = ast_primary_plane_init(ast);
1890 ret = ast_cursor_plane_init(ast);
1896 if (ast->tx_chip_types & AST_TX_NONE_BIT) {
1897 ret = ast_vga_output_init(ast);
1900 physical_connector = &ast->output.vga.connector;
1902 if (ast->tx_chip_types & AST_TX_SIL164_BIT) {
1903 ret = ast_sil164_output_init(ast);
1906 physical_connector = &ast->output.sil164.connector;
1908 if (ast->tx_chip_types & AST_TX_DP501_BIT) {
1909 ret = ast_dp501_output_init(ast);
1912 physical_connector = &ast->output.dp501.connector;
1914 if (ast->tx_chip_types & AST_TX_ASTDP_BIT) {
1915 ret = ast_astdp_output_init(ast);
1918 physical_connector = &ast->output.astdp.connector;
1920 ret = ast_bmc_output_init(ast, physical_connector);