45 if (sdev->meram_dev && sdev->meram_dev->pdev)
46 pm_runtime_get_sync(&sdev->meram_dev->pdev->
dev);
53 if (sdev->meram_dev && sdev->meram_dev->pdev)
54 pm_runtime_put_sync(&sdev->meram_dev->pdev->
dev);
64 static void shmob_drm_crtc_setup_geometry(
struct shmob_drm_crtc *scrtc)
80 lcdc_write(sdev,
LDMT1R, value);
91 lcdc_write(sdev,
LDMT2R, value);
97 lcdc_write(sdev,
LDMT3R, value);
100 value = ((mode->
hdisplay / 8) << 16)
102 lcdc_write(sdev,
LDHCNR, value);
106 lcdc_write(sdev,
LDHSYNR, value);
111 lcdc_write(sdev,
LDHAJR, value);
115 lcdc_write(sdev,
LDVLNR, value);
119 lcdc_write(sdev,
LDVSYNR, value);
127 value = lcdc_read(sdev,
LDCNT2R);
136 if ((start && value) || (!start && !value))
173 shmob_drm_clk_on(sdev);
181 shmob_drm_crtc_start_stop(scrtc,
false);
182 lcdc_write(sdev,
LDINTR, 0);
185 lcdc_write(sdev,
LDPMR, 0);
201 lcdc_write(sdev,
LDDCKR, value);
208 shmob_drm_crtc_setup_geometry(scrtc);
216 lcdc_write(sdev,
LDSM1R, 0);
237 lcdc_write(sdev,
LDDDSR, value);
241 if (plane->
crtc == crtc)
248 shmob_drm_crtc_start_stop(scrtc,
true);
268 shmob_drm_crtc_start_stop(scrtc,
false);
274 shmob_drm_clk_off(sdev);
281 shmob_drm_crtc_stop(scrtc);
289 shmob_drm_crtc_start(scrtc);
292 static void shmob_drm_crtc_compute_base(
struct shmob_drm_crtc *scrtc,
304 + y * fb->
pitches[0] + x * bpp / 8;
307 bpp = scrtc->
format->bpp - 8;
310 + y / (bpp == 4 ? 2 : 1) * fb->
pitches[1]
311 + x * (bpp == 16 ? 2 : 1);
316 scrtc->
dma[0], scrtc->
dma[1],
317 &scrtc->
dma[0], &scrtc->
dma[1]);
320 static void shmob_drm_crtc_update_base(
struct shmob_drm_crtc *scrtc)
325 shmob_drm_crtc_compute_base(scrtc, crtc->
x, crtc->
y);
327 lcdc_write_mirror(sdev,
LDSA1R, scrtc->
dma[0]);
329 lcdc_write_mirror(sdev,
LDSA2R, scrtc->
dma[1]);
334 #define to_shmob_crtc(c) container_of(c, struct shmob_drm_crtc, crtc)
336 static void shmob_drm_crtc_dpms(
struct drm_crtc *crtc,
int mode)
340 if (scrtc->
dpms == mode)
344 shmob_drm_crtc_start(scrtc);
346 shmob_drm_crtc_stop(scrtc);
351 static bool shmob_drm_crtc_mode_fixup(
struct drm_crtc *crtc,
358 static void shmob_drm_crtc_mode_prepare(
struct drm_crtc *crtc)
363 static int shmob_drm_crtc_mode_set(
struct drm_crtc *crtc,
376 if (format ==
NULL) {
377 dev_dbg(sdev->
dev,
"mode_set: unsupported format %08x\n",
378 crtc->
fb->pixel_format);
395 crtc->
fb->pitches[0],
403 shmob_drm_crtc_compute_base(scrtc, x, y);
408 static void shmob_drm_crtc_mode_commit(
struct drm_crtc *crtc)
413 static int shmob_drm_crtc_mode_set_base(
struct drm_crtc *crtc,
int x,
int y,
422 .dpms = shmob_drm_crtc_dpms,
423 .mode_fixup = shmob_drm_crtc_mode_fixup,
424 .prepare = shmob_drm_crtc_mode_prepare,
425 .commit = shmob_drm_crtc_mode_commit,
426 .mode_set = shmob_drm_crtc_mode_set,
427 .mode_set_base = shmob_drm_crtc_mode_set_base,
431 struct drm_file *
file)
433 struct drm_pending_vblank_event *
event;
441 event = scrtc->
event;
442 if (event && event->base.file_priv == file) {
444 event->base.destroy(&event->base);
447 spin_unlock_irqrestore(&dev->event_lock, flags);
452 struct drm_pending_vblank_event *
event;
458 event = scrtc->
event;
460 spin_unlock_irqrestore(&dev->event_lock, flags);
466 event->event.tv_sec = vblanktime.
tv_sec;
467 event->event.tv_usec = vblanktime.
tv_usec;
470 list_add_tail(&event->base.link, &event->base.file_priv->event_list);
472 spin_unlock_irqrestore(&dev->event_lock, flags);
477 static int shmob_drm_crtc_page_flip(
struct drm_crtc *crtc,
479 struct drm_pending_vblank_event *
event)
487 spin_unlock_irqrestore(&dev->event_lock, flags);
490 spin_unlock_irqrestore(&dev->event_lock, flags);
493 shmob_drm_crtc_update_base(scrtc);
499 spin_unlock_irqrestore(&dev->event_lock, flags);
509 .page_flip = shmob_drm_crtc_page_flip,
523 drm_crtc_helper_add(crtc, &crtc_helper_funcs);
532 #define to_shmob_encoder(e) \
533 container_of(e, struct shmob_drm_encoder, encoder)
535 static void shmob_drm_encoder_dpms(
struct drm_encoder *encoder,
int mode)
541 if (senc->
dpms == mode)
558 if (list_empty(&connector->
modes)) {
559 dev_dbg(dev->dev,
"mode_fixup: empty modes list\n");
571 static void shmob_drm_encoder_mode_prepare(
struct drm_encoder *encoder)
576 static void shmob_drm_encoder_mode_set(
struct drm_encoder *encoder,
583 static void shmob_drm_encoder_mode_commit(
struct drm_encoder *encoder)
589 .dpms = shmob_drm_encoder_dpms,
590 .mode_fixup = shmob_drm_encoder_mode_fixup,
591 .prepare = shmob_drm_encoder_mode_prepare,
592 .commit = shmob_drm_encoder_mode_commit,
593 .mode_set = shmob_drm_encoder_mode_set,
596 static void shmob_drm_encoder_destroy(
struct drm_encoder *encoder)
602 .destroy = shmob_drm_encoder_destroy,
619 drm_encoder_helper_add(encoder, &encoder_helper_funcs);
636 lcdc_write(sdev,
LDINTR, ldintr);
637 spin_unlock_irqrestore(&sdev->
irq_lock, flags);
644 #define to_shmob_connector(c) \
645 container_of(c, struct shmob_drm_connector, connector)
647 static int shmob_drm_connector_get_modes(
struct drm_connector *connector)
677 static int shmob_drm_connector_mode_valid(
struct drm_connector *connector,
684 shmob_drm_connector_best_encoder(
struct drm_connector *connector)
692 .get_modes = shmob_drm_connector_get_modes,
693 .mode_valid = shmob_drm_connector_mode_valid,
694 .best_encoder = shmob_drm_connector_best_encoder,
697 static void shmob_drm_connector_destroy(
struct drm_connector *connector)
714 .detect = shmob_drm_connector_detect,
716 .destroy = shmob_drm_connector_destroy,
735 drm_connector_helper_add(connector, &connector_helper_funcs);