24 #define CIRRUS_LUT_SIZE 256
26 #define PALETTE_INDEX 0x8
27 #define PALETTE_DATA 0x9
98 static bool cirrus_crtc_mode_fixup(
struct drm_crtc *crtc,
118 tmp |= (addr >> 16) & 0x01;
119 tmp |= (addr >> 15) & 0x0c;
124 tmp |= (addr >> 12) & 0x80;
129 static int cirrus_crtc_do_set_base(
struct drm_crtc *crtc,
131 int x,
int y,
int atomic)
134 struct drm_gem_object *obj;
143 obj = cirrus_fb->
obj;
153 obj = cirrus_fb->
obj;
166 if (&cdev->
mode_info.gfbdev->gfb == cirrus_fb) {
170 DRM_ERROR(
"failed to kmap fbcon\n");
178 static int cirrus_crtc_mode_set_base(
struct drm_crtc *crtc,
int x,
int y,
181 return cirrus_crtc_do_set_base(crtc, old_fb, x, y, 0);
192 static int cirrus_crtc_mode_set(
struct drm_crtc *crtc,
199 int hsyncstart, hsyncend, htotal, hdispend;
200 int vtotal, vdispend;
202 int sr07 = 0,
hdr = 0;
204 htotal = mode->
htotal / 8;
229 if ((vdispend + 1) & 512)
241 if ((vdispend + 1) & 256)
253 if ((htotal + 5) & 64)
255 if ((htotal + 5) & 128)
271 switch (crtc->
fb->bits_per_pixel) {
294 tmp = crtc->
fb->pitches[0] / 8;
299 tmp |= (crtc->
fb->pitches[0] >> 7) & 0x10;
300 tmp |= (crtc->
fb->pitches[0] >> 6) & 0x40;
310 cirrus_crtc_do_set_base(crtc, old_fb, x, y, 0);
319 static void cirrus_crtc_prepare(
struct drm_crtc *crtc)
327 static void cirrus_crtc_commit(
struct drm_crtc *crtc)
346 cirrus_crtc->
lut_r[
i] = red[
i];
347 cirrus_crtc->
lut_g[
i] = green[
i];
348 cirrus_crtc->
lut_b[
i] = blue[
i];
350 cirrus_crtc_load_lut(crtc);
354 static void cirrus_crtc_destroy(
struct drm_crtc *crtc)
364 .gamma_set = cirrus_crtc_gamma_set,
366 .destroy = cirrus_crtc_destroy,
370 .dpms = cirrus_crtc_dpms,
371 .mode_fixup = cirrus_crtc_mode_fixup,
372 .mode_set = cirrus_crtc_mode_set,
373 .mode_set_base = cirrus_crtc_mode_set_base,
374 .prepare = cirrus_crtc_prepare,
375 .commit = cirrus_crtc_commit,
376 .load_lut = cirrus_crtc_load_lut,
380 static void cirrus_crtc_init(
struct drm_device *dev)
383 struct cirrus_crtc *cirrus_crtc;
386 cirrus_crtc = kzalloc(
sizeof(
struct cirrus_crtc) +
390 if (cirrus_crtc ==
NULL)
404 drm_crtc_helper_add(&cirrus_crtc->
base, &cirrus_helper_funcs);
420 u16 *blue,
int regno)
424 *red = cirrus_crtc->
lut_r[regno];
425 *green = cirrus_crtc->
lut_g[regno];
426 *blue = cirrus_crtc->
lut_b[regno];
430 static bool cirrus_encoder_mode_fixup(
struct drm_encoder *encoder,
437 static void cirrus_encoder_mode_set(
struct drm_encoder *encoder,
448 static void cirrus_encoder_prepare(
struct drm_encoder *encoder)
452 static void cirrus_encoder_commit(
struct drm_encoder *encoder)
460 kfree(cirrus_encoder);
464 .dpms = cirrus_encoder_dpms,
465 .mode_fixup = cirrus_encoder_mode_fixup,
466 .mode_set = cirrus_encoder_mode_set,
467 .prepare = cirrus_encoder_prepare,
468 .commit = cirrus_encoder_commit,
480 cirrus_encoder = kzalloc(
sizeof(
struct cirrus_encoder),
GFP_KERNEL);
484 encoder = &cirrus_encoder->
base;
489 drm_encoder_helper_add(encoder, &cirrus_encoder_helper_funcs);
547 .mode_valid = cirrus_vga_mode_valid,
553 .detect = cirrus_vga_detect,
555 .destroy = cirrus_connector_destroy,
563 cirrus_connector = kzalloc(
sizeof(
struct cirrus_connector),
GFP_KERNEL);
564 if (!cirrus_connector)
567 connector = &cirrus_connector->
base;
572 drm_connector_helper_add(connector, &cirrus_vga_connector_helper_funcs);
585 cdev->
mode_info.mode_config_initialized =
true;
590 cdev->
dev->mode_config.fb_base = cdev->
mc.vram_base;
591 cdev->
dev->mode_config.preferred_depth = 24;
593 cdev->
dev->mode_config.prefer_shadow = 0;
595 cirrus_crtc_init(cdev->
dev);
597 encoder = cirrus_encoder_init(cdev->
dev);
599 DRM_ERROR(
"cirrus_encoder_init failed\n");
603 connector = cirrus_vga_init(cdev->
dev);
605 DRM_ERROR(
"cirrus_vga_init failed\n");
613 DRM_ERROR(
"cirrus_fbdev_init failed\n");
624 if (cdev->
mode_info.mode_config_initialized) {
626 cdev->
mode_info.mode_config_initialized =
false;