/* * Copyright 2012 Red Hat Inc. * Parts based on xf86-video-ast * Copyright (c) 2005 ASPEED Technology Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. *
*/ /* * Authors: Dave Airlie <airlied@redhat.com>
*/
switch (format->format) { case DRM_FORMAT_C8: /* gamma table is used as color palette */
drm_crtc_fill_palette_8(crtc, ast_set_gamma_lut); break; case DRM_FORMAT_RGB565: /* also uses 8-bit gamma ramp on low-color modes */
fallthrough; case DRM_FORMAT_XRGB8888:
drm_crtc_fill_gamma_888(crtc, ast_set_gamma_lut); break; default:
drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n",
&format->format); break;
}
}
switch (format->format) { case DRM_FORMAT_C8: /* gamma table is used as color palette */
drm_crtc_load_palette_8(crtc, lut, ast_set_gamma_lut); break; case DRM_FORMAT_RGB565: /* also uses 8-bit gamma ramp on low-color modes */
fallthrough; case DRM_FORMAT_XRGB8888:
drm_crtc_load_gamma_888(crtc, lut, ast_set_gamma_lut); break; default:
drm_warn_once(&ast->base, "Unsupported format %p4cc for gamma correction\n",
&format->format); break;
}
}
/* Set SEQ; except Screen Disable field */
ast_set_index_reg(ast, AST_IO_VGASRI, 0x00, 0x03);
ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0x20, stdtable->seq[0]); for (i = 1; i < 4; i++) {
jreg = stdtable->seq[i];
ast_set_index_reg(ast, AST_IO_VGASRI, (i + 1), jreg);
}
/* Set CRTC; except base address and offset */
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0x11, 0x7f, 0x00); for (i = 0; i < 12; i++)
ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]); for (i = 14; i < 19; i++)
ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]); for (i = 20; i < 25; i++)
ast_set_index_reg(ast, AST_IO_VGACRI, i, stdtable->crtc[i]);
/* set AR */
jreg = ast_io_read8(ast, AST_IO_VGAIR1_R); for (i = 0; i < 20; i++) {
jreg = stdtable->ar[i];
ast_io_write8(ast, AST_IO_VGAARI_W, (u8)i);
ast_io_write8(ast, AST_IO_VGAARI_W, jreg);
}
ast_io_write8(ast, AST_IO_VGAARI_W, 0x14);
ast_io_write8(ast, AST_IO_VGAARI_W, 0x00);
/* * Some BMCs stop scanning out the video signal after the driver * reprogrammed the offset. This stalls display output for several * seconds and makes the display unusable. Therefore only update * the offset if it changes.
*/ if (!old_fb || old_fb->pitches[0] != fb->pitches[0])
ast_set_offset_reg(ast, fb);
}
/* * Some BMCs stop scanning out the video signal after the driver * reprogrammed the scanout address. This stalls display * output for several seconds and makes the display unusable. * Therefore only reprogram the address after enabling the plane.
*/
ast_set_start_address_crt1(ast, (u32)ast_plane->offset);
}
staticvoid ast_primary_plane_helper_atomic_disable(struct drm_plane *plane, struct drm_atomic_state *state)
{ /* * Keep this empty function to avoid calling * atomic_update when disabling the plane.
*/
}
/* * Ensure that no scanout takes place before reprogramming mode * and format registers. * * TODO: Get vblank interrupts working and remove this line.
*/
ast_wait_for_vretrace(ast);
ret = drm_atomic_helper_check_crtc_primary_plane(crtc_state); if (ret) return ret;
ast_state = to_ast_crtc_state(crtc_state);
format = ast_state->format; if (drm_WARN_ON_ONCE(dev, !format)) return -EINVAL; /* BUG: We didn't set format in primary check(). */
/* * The gamma LUT has to be reloaded after changing the primary * plane's color format.
*/ if (old_ast_crtc_state->format != format)
crtc_state->color_mgmt_changed = true;
if (crtc_state->color_mgmt_changed && crtc_state->gamma_lut) { if (crtc_state->gamma_lut->length !=
AST_LUT_SIZE * sizeof(struct drm_color_lut)) {
drm_err(dev, "Wrong size for gamma_lut %zu\n",
crtc_state->gamma_lut->length); return -EINVAL;
}
}
/* * Set register tables. * * TODO: These tables mix all kinds of fields and should * probably be resolved into various helper functions.
*/ switch (format->format) { case DRM_FORMAT_C8:
ast_state->std_table = &vbios_stdtable[VGAModeIndex]; break; case DRM_FORMAT_RGB565:
ast_state->std_table = &vbios_stdtable[HiCModeIndex]; break; case DRM_FORMAT_RGB888: case DRM_FORMAT_XRGB8888:
ast_state->std_table = &vbios_stdtable[TrueCModeIndex]; break; default: return -EINVAL;
}
/* * Find the VBIOS mode and adjust the DRM display mode accordingly * if a full modeset is required. Otherwise keep the existing values.
*/ if (drm_atomic_crtc_needs_modeset(crtc_state)) {
vmode = ast_vbios_find_mode(ast, &crtc_state->mode); if (!vmode) return -EINVAL;
ast_state->vmode = vmode;
if (vmode->flags & HBorder)
hborder = 8; if (vmode->flags & VBorder)
vborder = 8;
/* * The gamma LUT has to be reloaded after changing the primary * plane's color format.
*/ if (crtc_state->enable && crtc_state->color_mgmt_changed) { if (crtc_state->gamma_lut)
ast_crtc_load_gamma(ast,
ast_crtc_state->format,
crtc_state->gamma_lut->data); else
ast_crtc_fill_gamma(ast, ast_crtc_state->format);
}
}
/* * HW cursors require the underlying primary plane and CRTC to * display a valid mode and image. This is not the case during * full modeset operations. So we temporarily disable any active * plane, including the HW cursor. Each plane's atomic_update() * helper will re-enable it if necessary. * * We only do this during *full* modesets. It does not affect * simple pageflips on the planes.
*/
drm_atomic_helper_disable_planes_on_crtc(old_crtc_state, false);
}
/* * Concurrent operations could possibly trigger a call to * drm_connector_helper_funcs.get_modes by reading the display * modes. Protect access to registers by acquiring the modeset * lock.
*/
mutex_lock(&ast->modeset_lock);
drm_atomic_helper_commit_tail(state);
mutex_unlock(&ast->modeset_lock);
}
ret = ast_primary_plane_init(ast); if (ret) return ret;
ret = ast_cursor_plane_init(ast); if (ret) return ret;
ret = ast_crtc_init(ast); if (ret) return ret;
switch (ast->tx_chip) { case AST_TX_NONE:
ret = ast_vga_output_init(ast); break; case AST_TX_SIL164:
ret = ast_sil164_output_init(ast); break; case AST_TX_DP501:
ret = ast_dp501_output_init(ast); break; case AST_TX_ASTDP:
ret = ast_astdp_output_init(ast); break;
} if (ret) return ret;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.14Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.