32 static char *udl_vidreg_lock(
char *
buf)
34 return udl_set_register(buf, 0xFF, 0x00);
37 static char *udl_vidreg_unlock(
char *
buf)
39 return udl_set_register(buf, 0xFF, 0xFF);
48 static char *udl_set_blank(
char *
buf,
int dpms_mode)
66 return udl_set_register(buf, 0x1f, reg);
69 static char *udl_set_color_depth(
char *buf,
u8 selection)
71 return udl_set_register(buf, 0x00, selection);
74 static char *udl_set_base16bpp(
char *wrptr,
u32 base)
77 wrptr = udl_set_register(wrptr, 0x20, base >> 16);
78 wrptr = udl_set_register(wrptr, 0x21, base >> 8);
79 return udl_set_register(wrptr, 0x22, base);
86 static char *udl_set_base8bpp(
char *wrptr,
u32 base)
88 wrptr = udl_set_register(wrptr, 0x26, base >> 16);
89 wrptr = udl_set_register(wrptr, 0x27, base >> 8);
90 return udl_set_register(wrptr, 0x28, base);
93 static char *udl_set_register_16(
char *wrptr,
u8 reg,
u16 value)
95 wrptr = udl_set_register(wrptr, reg, value >> 8);
96 return udl_set_register(wrptr, reg+1, value);
103 static char *udl_set_register_16be(
char *wrptr,
u8 reg,
u16 value)
105 wrptr = udl_set_register(wrptr, reg, value);
106 return udl_set_register(wrptr, reg+1, value >> 8);
118 static u16 udl_lfsr16(
u16 actual_count)
122 while (actual_count--) {
124 (((lv >> 15) ^ (lv >> 4) ^ (lv >> 2) ^ (lv >> 1)) & 1))
135 static char *udl_set_register_lfsr16(
char *wrptr,
u8 reg,
u16 value)
137 return udl_set_register_16(wrptr, reg, udl_lfsr16(value));
170 wrptr = udl_set_register_lfsr16(wrptr, 0x01, xds);
173 wrptr = udl_set_register_lfsr16(wrptr, 0x03, xde);
177 wrptr = udl_set_register_lfsr16(wrptr, 0x05, yds);
180 wrptr = udl_set_register_lfsr16(wrptr, 0x07, yde);
183 wrptr = udl_set_register_lfsr16(wrptr, 0x09,
187 wrptr = udl_set_register_lfsr16(wrptr, 0x0B, 1);
190 wrptr = udl_set_register_lfsr16(wrptr, 0x0D,
194 wrptr = udl_set_register_16(wrptr, 0x0F, mode->
hdisplay);
198 wrptr = udl_set_register_lfsr16(wrptr, 0x11, yec);
201 wrptr = udl_set_register_lfsr16(wrptr, 0x13, 0);
207 wrptr = udl_set_register_16(wrptr, 0x17, mode->
crtc_vdisplay);
209 wrptr = udl_set_register_16be(wrptr, 0x1B,
215 static char *udl_dummy_render(
char *wrptr)
229 static int udl_crtc_write_mode_to_hw(
struct drm_crtc *
crtc)
241 buf = (
char *)urb->transfer_buffer;
250 static void udl_crtc_dpms(
struct drm_crtc *crtc,
int mode)
263 buf = (
char *)urb->transfer_buffer;
264 buf = udl_vidreg_lock(buf);
265 buf = udl_set_blank(buf, mode);
266 buf = udl_vidreg_unlock(buf);
268 buf = udl_dummy_render(buf);
270 urb->transfer_buffer);
273 DRM_ERROR(
"Trying to enable DPMS with no mode\n");
276 udl_crtc_write_mode_to_hw(crtc);
281 static bool udl_crtc_mode_fixup(
struct drm_crtc *crtc,
298 udl_pipe_set_base(
struct drm_crtc *crtc,
int x,
int y,
305 static int udl_crtc_mode_set(
struct drm_crtc *crtc,
329 wrptr = udl_vidreg_lock(buf);
330 wrptr = udl_set_color_depth(wrptr, color_depth);
332 wrptr = udl_set_base16bpp(wrptr, 0);
336 wrptr = udl_set_vid_cmds(wrptr, adjusted_mode);
338 wrptr = udl_vidreg_unlock(wrptr);
340 wrptr = udl_dummy_render(wrptr);
355 static void udl_crtc_disable(
struct drm_crtc *crtc)
360 static void udl_crtc_destroy(
struct drm_crtc *crtc)
366 static void udl_load_lut(
struct drm_crtc *crtc)
370 static void udl_crtc_prepare(
struct drm_crtc *crtc)
374 static void udl_crtc_commit(
struct drm_crtc *crtc)
380 .dpms = udl_crtc_dpms,
381 .mode_fixup = udl_crtc_mode_fixup,
382 .mode_set = udl_crtc_mode_set,
383 .prepare = udl_crtc_prepare,
384 .commit = udl_crtc_commit,
385 .disable = udl_crtc_disable,
386 .load_lut = udl_load_lut,
391 .destroy = udl_crtc_destroy,
394 static int udl_crtc_init(
struct drm_device *dev)
403 drm_crtc_helper_add(crtc, &udl_helper_funcs);
410 .output_poll_changed =
NULL,
418 dev->mode_config.min_width = 640;
419 dev->mode_config.min_height = 480;
421 dev->mode_config.max_width = 2048;
422 dev->mode_config.max_height = 2048;
424 dev->mode_config.prefer_shadow = 0;
425 dev->mode_config.preferred_depth = 24;
427 dev->mode_config.funcs = &udl_mode_funcs;