Lines Matching refs:ast

53 static inline void ast_load_palette_index(struct ast_device *ast,  in ast_load_palette_index()  argument
57 ast_io_write8(ast, AST_IO_VGADWR, index); in ast_load_palette_index()
58 ast_io_read8(ast, AST_IO_VGASRI); in ast_load_palette_index()
59 ast_io_write8(ast, AST_IO_VGAPDR, red); in ast_load_palette_index()
60 ast_io_read8(ast, AST_IO_VGASRI); in ast_load_palette_index()
61 ast_io_write8(ast, AST_IO_VGAPDR, green); in ast_load_palette_index()
62 ast_io_read8(ast, AST_IO_VGASRI); in ast_load_palette_index()
63 ast_io_write8(ast, AST_IO_VGAPDR, blue); in ast_load_palette_index()
64 ast_io_read8(ast, AST_IO_VGASRI); in ast_load_palette_index()
67 static void ast_crtc_set_gamma_linear(struct ast_device *ast, in ast_crtc_set_gamma_linear() argument
77 ast_load_palette_index(ast, i, i, i, i); in ast_crtc_set_gamma_linear()
80 drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n", in ast_crtc_set_gamma_linear()
86 static void ast_crtc_set_gamma(struct ast_device *ast, in ast_crtc_set_gamma() argument
97 ast_load_palette_index(ast, i, in ast_crtc_set_gamma()
103 drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n", in ast_crtc_set_gamma()
234 static void ast_set_vbios_color_reg(struct ast_device *ast, in ast_set_vbios_color_reg() argument
255 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8c, (u8)((color_index & 0x0f) << 4)); in ast_set_vbios_color_reg()
257 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0x00); in ast_set_vbios_color_reg()
260 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0xa8); in ast_set_vbios_color_reg()
261 ast_set_index_reg(ast, AST_IO_VGACRI, 0x92, format->cpp[0] * 8); in ast_set_vbios_color_reg()
265 static void ast_set_vbios_mode_reg(struct ast_device *ast, in ast_set_vbios_mode_reg() argument
274 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8d, refresh_rate_index & 0xff); in ast_set_vbios_mode_reg()
275 ast_set_index_reg(ast, AST_IO_VGACRI, 0x8e, mode_id & 0xff); in ast_set_vbios_mode_reg()
277 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0x00); in ast_set_vbios_mode_reg()
280 ast_set_index_reg(ast, AST_IO_VGACRI, 0x91, 0xa8); in ast_set_vbios_mode_reg()
281 ast_set_index_reg(ast, AST_IO_VGACRI, 0x93, adjusted_mode->clock / 1000); in ast_set_vbios_mode_reg()
282 ast_set_index_reg(ast, AST_IO_VGACRI, 0x94, adjusted_mode->crtc_hdisplay); in ast_set_vbios_mode_reg()
283 ast_set_index_reg(ast, AST_IO_VGACRI, 0x95, adjusted_mode->crtc_hdisplay >> 8); in ast_set_vbios_mode_reg()
284 ast_set_index_reg(ast, AST_IO_VGACRI, 0x96, adjusted_mode->crtc_vdisplay); in ast_set_vbios_mode_reg()
285 ast_set_index_reg(ast, AST_IO_VGACRI, 0x97, adjusted_mode->crtc_vdisplay >> 8); in ast_set_vbios_mode_reg()
289 static void ast_set_std_reg(struct ast_device *ast, in ast_set_std_reg() argument
300 ast_io_write8(ast, AST_IO_VGAMR_W, jreg); in ast_set_std_reg()
303 ast_set_index_reg(ast, AST_IO_VGASRI, 0x00, 0x03); in ast_set_std_reg()
304 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0x20, stdtable->seq[0]); in ast_set_std_reg()
307 ast_set_index_reg(ast, AST_IO_VGASRI, (i + 1), jreg); in ast_set_std_reg()
311 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00); in ast_set_std_reg()
313 ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]); in ast_set_std_reg()
315 ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]); in ast_set_std_reg()
317 ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]); in ast_set_std_reg()
320 jreg = ast_io_read8(ast, AST_IO_VGAIR1_R); in ast_set_std_reg()
323 ast_io_write8(ast, AST_IO_VGAARI_W, (u8)i); in ast_set_std_reg()
324 ast_io_write8(ast, AST_IO_VGAARI_W, jreg); in ast_set_std_reg()
326 ast_io_write8(ast, AST_IO_VGAARI_W, 0x14); in ast_set_std_reg()
327 ast_io_write8(ast, AST_IO_VGAARI_W, 0x00); in ast_set_std_reg()
329 jreg = ast_io_read8(ast, AST_IO_VGAIR1_R); in ast_set_std_reg()
330 ast_io_write8(ast, AST_IO_VGAARI_W, 0x20); in ast_set_std_reg()
334 ast_set_index_reg(ast, AST_IO_VGAGRI, i, stdtable->gr[i]); in ast_set_std_reg()
337 static void ast_set_crtc_reg(struct ast_device *ast, in ast_set_crtc_reg() argument
344 if ((IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) && in ast_set_crtc_reg()
348 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00); in ast_set_crtc_reg()
353 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x00, 0x00, temp); in ast_set_crtc_reg()
358 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x01, 0x00, temp); in ast_set_crtc_reg()
363 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x02, 0x00, temp); in ast_set_crtc_reg()
370 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x03, 0xE0, (temp & 0x1f)); in ast_set_crtc_reg()
375 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x04, 0x00, temp); in ast_set_crtc_reg()
380 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x05, 0x60, (u8)((temp & 0x1f) | jreg05)); in ast_set_crtc_reg()
382 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAC, 0x00, jregAC); in ast_set_crtc_reg()
383 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAD, 0x00, jregAD); in ast_set_crtc_reg()
386 if (IS_AST_GEN7(ast) && (mode->crtc_vdisplay == 1080)) in ast_set_crtc_reg()
387 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xFC, 0xFD, 0x02); in ast_set_crtc_reg()
389 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xFC, 0xFD, 0x00); in ast_set_crtc_reg()
399 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x06, 0x00, temp); in ast_set_crtc_reg()
408 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x10, 0x00, temp); in ast_set_crtc_reg()
415 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x70, temp & 0xf); in ast_set_crtc_reg()
424 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x12, 0x00, temp); in ast_set_crtc_reg()
433 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x15, 0x00, temp); in ast_set_crtc_reg()
438 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x16, 0x00, temp); in ast_set_crtc_reg()
440 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x07, 0x00, jreg07); in ast_set_crtc_reg()
441 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x09, 0xdf, jreg09); in ast_set_crtc_reg()
442 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xAE, 0x00, (jregAE | 0x80)); in ast_set_crtc_reg()
445 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x80); in ast_set_crtc_reg()
447 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0x3f, 0x00); in ast_set_crtc_reg()
449 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x80); in ast_set_crtc_reg()
452 static void ast_set_offset_reg(struct ast_device *ast, in ast_set_offset_reg() argument
458 ast_set_index_reg(ast, AST_IO_VGACRI, 0x13, (offset & 0xff)); in ast_set_offset_reg()
459 ast_set_index_reg(ast, AST_IO_VGACRI, 0xb0, (offset >> 8) & 0x3f); in ast_set_offset_reg()
462 static void ast_set_dclk_reg(struct ast_device *ast, in ast_set_dclk_reg() argument
468 if (IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) in ast_set_dclk_reg()
473 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xc0, 0x00, clk_info->param1); in ast_set_dclk_reg()
474 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xc1, 0x00, clk_info->param2); in ast_set_dclk_reg()
475 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xbb, 0x0f, in ast_set_dclk_reg()
480 static void ast_set_color_reg(struct ast_device *ast, in ast_set_color_reg() argument
504 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa0, 0x8f, jregA0); in ast_set_color_reg()
505 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa3, 0xf0, jregA3); in ast_set_color_reg()
506 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xa8, 0xfd, jregA8); in ast_set_color_reg()
509 static void ast_set_crtthd_reg(struct ast_device *ast) in ast_set_crtthd_reg() argument
512 if (IS_AST_GEN7(ast)) { in ast_set_crtthd_reg()
513 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0xe0); in ast_set_crtthd_reg()
514 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0xa0); in ast_set_crtthd_reg()
515 } else if (IS_AST_GEN6(ast) || IS_AST_GEN5(ast) || IS_AST_GEN4(ast)) { in ast_set_crtthd_reg()
516 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x78); in ast_set_crtthd_reg()
517 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x60); in ast_set_crtthd_reg()
518 } else if (IS_AST_GEN3(ast) || IS_AST_GEN2(ast)) { in ast_set_crtthd_reg()
519 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x3f); in ast_set_crtthd_reg()
520 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x2f); in ast_set_crtthd_reg()
522 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa7, 0x2f); in ast_set_crtthd_reg()
523 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa6, 0x1f); in ast_set_crtthd_reg()
527 static void ast_set_sync_reg(struct ast_device *ast, in ast_set_sync_reg() argument
533 jreg = ast_io_read8(ast, AST_IO_VGAMR_R); in ast_set_sync_reg()
539 ast_io_write8(ast, AST_IO_VGAMR_W, jreg); in ast_set_sync_reg()
542 static void ast_set_start_address_crt1(struct ast_device *ast, in ast_set_start_address_crt1() argument
548 ast_set_index_reg(ast, AST_IO_VGACRI, 0x0d, (u8)(addr & 0xff)); in ast_set_start_address_crt1()
549 ast_set_index_reg(ast, AST_IO_VGACRI, 0x0c, (u8)((addr >> 8) & 0xff)); in ast_set_start_address_crt1()
550 ast_set_index_reg(ast, AST_IO_VGACRI, 0xaf, (u8)((addr >> 16) & 0xff)); in ast_set_start_address_crt1()
554 static void ast_wait_for_vretrace(struct ast_device *ast) in ast_wait_for_vretrace() argument
560 vgair1 = ast_io_read8(ast, AST_IO_VGAIR1_R); in ast_wait_for_vretrace()
643 struct ast_device *ast = to_ast_device(dev); in ast_primary_plane_helper_atomic_update() local
659 ast_set_color_reg(ast, fb->format); in ast_primary_plane_helper_atomic_update()
660 ast_set_vbios_color_reg(ast, fb->format, vbios_mode_info); in ast_primary_plane_helper_atomic_update()
675 ast_set_offset_reg(ast, fb); in ast_primary_plane_helper_atomic_update()
681 struct ast_device *ast = to_ast_device(plane->dev); in ast_primary_plane_helper_atomic_enable() local
690 ast_set_start_address_crt1(ast, (u32)ast_plane->offset); in ast_primary_plane_helper_atomic_enable()
734 static int ast_primary_plane_init(struct ast_device *ast) in ast_primary_plane_init() argument
736 struct drm_device *dev = &ast->base; in ast_primary_plane_init()
737 struct ast_plane *ast_primary_plane = &ast->primary_plane; in ast_primary_plane_init()
739 void __iomem *vaddr = ast->vram; in ast_primary_plane_init()
742 unsigned long size = ast->vram_fb_available - cursor_size; in ast_primary_plane_init()
827 static void ast_set_cursor_base(struct ast_device *ast, u64 address) in ast_set_cursor_base() argument
833 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc8, addr0); in ast_set_cursor_base()
834 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc9, addr1); in ast_set_cursor_base()
835 ast_set_index_reg(ast, AST_IO_VGACRI, 0xca, addr2); in ast_set_cursor_base()
838 static void ast_set_cursor_location(struct ast_device *ast, u16 x, u16 y, in ast_set_cursor_location() argument
846 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc2, x_offset); in ast_set_cursor_location()
847 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc3, y_offset); in ast_set_cursor_location()
848 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc4, x0); in ast_set_cursor_location()
849 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc5, x1); in ast_set_cursor_location()
850 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc6, y0); in ast_set_cursor_location()
851 ast_set_index_reg(ast, AST_IO_VGACRI, 0xc7, y1); in ast_set_cursor_location()
854 static void ast_set_cursor_enabled(struct ast_device *ast, bool enabled) in ast_set_cursor_enabled() argument
864 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xcb, mask, vgacrcb); in ast_set_cursor_enabled()
903 struct ast_device *ast = to_ast_device(plane->dev); in ast_cursor_plane_helper_atomic_update() local
921 ast_set_cursor_base(ast, dst_off); in ast_cursor_plane_helper_atomic_update()
949 ast_set_cursor_location(ast, x, y, x_offset, y_offset); in ast_cursor_plane_helper_atomic_update()
952 ast_set_cursor_enabled(ast, true); in ast_cursor_plane_helper_atomic_update()
958 struct ast_device *ast = to_ast_device(plane->dev); in ast_cursor_plane_helper_atomic_disable() local
960 ast_set_cursor_enabled(ast, false); in ast_cursor_plane_helper_atomic_disable()
977 static int ast_cursor_plane_init(struct ast_device *ast) in ast_cursor_plane_init() argument
979 struct drm_device *dev = &ast->base; in ast_cursor_plane_init()
980 struct ast_plane *ast_cursor_plane = &ast->cursor_plane; in ast_cursor_plane_init()
994 if (ast->vram_fb_available < size) in ast_cursor_plane_init()
997 vaddr = ast->vram + ast->vram_fb_available - size; in ast_cursor_plane_init()
998 offset = ast->vram_fb_available - size; in ast_cursor_plane_init()
1011 ast->vram_fb_available -= size; in ast_cursor_plane_init()
1023 struct ast_device *ast = to_ast_device(crtc->dev); in ast_crtc_helper_mode_valid() local
1027 if (ast->support_wide_screen) { in ast_crtc_helper_mode_valid()
1041 if ((ast->chip == AST2100) || // GEN2, but not AST1100 (?) in ast_crtc_helper_mode_valid()
1042 (ast->chip == AST2200) || // GEN3, but not AST2150 (?) in ast_crtc_helper_mode_valid()
1043 IS_AST_GEN4(ast) || IS_AST_GEN5(ast) || in ast_crtc_helper_mode_valid()
1044 IS_AST_GEN6(ast) || IS_AST_GEN7(ast)) { in ast_crtc_helper_mode_valid()
1049 jtemp = ast_get_index_reg_mask(ast, AST_IO_VGACRI, 0xd1, 0xff); in ast_crtc_helper_mode_valid()
1095 struct ast_device *ast = to_ast_device(dev); in ast_crtc_helper_mode_set_nofb() local
1108 ast_wait_for_vretrace(ast); in ast_crtc_helper_mode_set_nofb()
1110 ast_set_vbios_mode_reg(ast, adjusted_mode, vbios_mode_info); in ast_crtc_helper_mode_set_nofb()
1111 ast_set_index_reg(ast, AST_IO_VGACRI, 0xa1, 0x06); in ast_crtc_helper_mode_set_nofb()
1112 ast_set_std_reg(ast, adjusted_mode, vbios_mode_info); in ast_crtc_helper_mode_set_nofb()
1113 ast_set_crtc_reg(ast, adjusted_mode, vbios_mode_info); in ast_crtc_helper_mode_set_nofb()
1114 ast_set_dclk_reg(ast, adjusted_mode, vbios_mode_info); in ast_crtc_helper_mode_set_nofb()
1115 ast_set_crtthd_reg(ast); in ast_crtc_helper_mode_set_nofb()
1116 ast_set_sync_reg(ast, adjusted_mode, vbios_mode_info); in ast_crtc_helper_mode_set_nofb()
1176 struct ast_device *ast = to_ast_device(dev); in ast_crtc_helper_atomic_flush() local
1185 ast_crtc_set_gamma(ast, in ast_crtc_helper_atomic_flush()
1189 ast_crtc_set_gamma_linear(ast, ast_crtc_state->format); in ast_crtc_helper_atomic_flush()
1195 struct ast_device *ast = to_ast_device(crtc->dev); in ast_crtc_helper_atomic_enable() local
1197 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xfc, 0x00); in ast_crtc_helper_atomic_enable()
1198 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, 0x00); in ast_crtc_helper_atomic_enable()
1204 struct ast_device *ast = to_ast_device(crtc->dev); in ast_crtc_helper_atomic_disable() local
1207 ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xdf, AST_IO_VGASR1_SD); in ast_crtc_helper_atomic_disable()
1211 ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xb6, 0xfc, vgacrb6); in ast_crtc_helper_atomic_disable()
1290 static int ast_crtc_init(struct ast_device *ast) in ast_crtc_init() argument
1292 struct drm_device *dev = &ast->base; in ast_crtc_init()
1293 struct drm_crtc *crtc = &ast->crtc; in ast_crtc_init()
1296 ret = drm_crtc_init_with_planes(dev, crtc, &ast->primary_plane.base, in ast_crtc_init()
1297 &ast->cursor_plane.base, &ast_crtc_funcs, in ast_crtc_init()
1316 struct ast_device *ast = to_ast_device(state->dev); in ast_mode_config_helper_atomic_commit_tail() local
1324 mutex_lock(&ast->modeset_lock); in ast_mode_config_helper_atomic_commit_tail()
1326 mutex_unlock(&ast->modeset_lock); in ast_mode_config_helper_atomic_commit_tail()
1337 struct ast_device *ast = to_ast_device(dev); in ast_mode_config_mode_valid() local
1340 max_fbpages = (ast->vram_fb_available) >> PAGE_SHIFT; in ast_mode_config_mode_valid()
1358 int ast_mode_config_init(struct ast_device *ast) in ast_mode_config_init() argument
1360 struct drm_device *dev = &ast->base; in ast_mode_config_init()
1363 ret = drmm_mutex_init(dev, &ast->modeset_lock); in ast_mode_config_init()
1376 if (ast->chip == AST2100 || // GEN2, but not AST1100 (?) in ast_mode_config_init()
1377 ast->chip == AST2200 || // GEN3, but not AST2150 (?) in ast_mode_config_init()
1378 IS_AST_GEN7(ast) || in ast_mode_config_init()
1379 IS_AST_GEN6(ast) || in ast_mode_config_init()
1380 IS_AST_GEN5(ast) || in ast_mode_config_init()
1381 IS_AST_GEN4(ast)) { in ast_mode_config_init()
1391 ret = ast_primary_plane_init(ast); in ast_mode_config_init()
1395 ret = ast_cursor_plane_init(ast); in ast_mode_config_init()
1399 ret = ast_crtc_init(ast); in ast_mode_config_init()
1403 switch (ast->tx_chip) { in ast_mode_config_init()
1405 ret = ast_vga_output_init(ast); in ast_mode_config_init()
1408 ret = ast_sil164_output_init(ast); in ast_mode_config_init()
1411 ret = ast_dp501_output_init(ast); in ast_mode_config_init()
1414 ret = ast_astdp_output_init(ast); in ast_mode_config_init()