Lines Matching +full:vco +full:- +full:hz

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2006-2011 Intel Corporation
32 struct drm_device *dev = crtc->dev; in gma_pipe_has_type()
38 if (connector->encoder && connector->encoder->crtc == crtc) { in gma_pipe_has_type()
41 if (gma_encoder->type == type) { in gma_pipe_has_type()
54 /* Wait for 20ms, i.e. one cycle at 50hz. */ in gma_wait_for_vblank()
61 struct drm_device *dev = crtc->dev; in gma_pipe_set_base()
64 struct drm_framebuffer *fb = crtc->primary->fb; in gma_pipe_set_base()
66 int pipe = gma_crtc->pipe; in gma_pipe_set_base()
67 const struct psb_offset *map = &dev_priv->regmap[pipe]; in gma_pipe_set_base()
77 dev_err(dev->dev, "No FB bound\n"); in gma_pipe_set_base()
81 pobj = to_psb_gem_object(fb->obj[0]); in gma_pipe_set_base()
88 start = pobj->offset; in gma_pipe_set_base()
89 offset = y * fb->pitches[0] + x * fb->format->cpp[0]; in gma_pipe_set_base()
91 REG_WRITE(map->stride, fb->pitches[0]); in gma_pipe_set_base()
93 dspcntr = REG_READ(map->cntr); in gma_pipe_set_base()
96 switch (fb->format->cpp[0] * 8) { in gma_pipe_set_base()
101 if (fb->format->depth == 15) in gma_pipe_set_base()
111 dev_err(dev->dev, "Unknown color depth\n"); in gma_pipe_set_base()
112 ret = -EINVAL; in gma_pipe_set_base()
115 REG_WRITE(map->cntr, dspcntr); in gma_pipe_set_base()
117 dev_dbg(dev->dev, in gma_pipe_set_base()
121 the linear offset is named base for the other chips. map->surf in gma_pipe_set_base()
122 should be the base and map->linoff the offset for all chips */ in gma_pipe_set_base()
124 REG_WRITE(map->base, offset + start); in gma_pipe_set_base()
125 REG_READ(map->base); in gma_pipe_set_base()
127 REG_WRITE(map->base, offset); in gma_pipe_set_base()
128 REG_READ(map->base); in gma_pipe_set_base()
129 REG_WRITE(map->surf, start); in gma_pipe_set_base()
130 REG_READ(map->surf); in gma_pipe_set_base()
136 psb_gem_unpin(to_psb_gem_object(old_fb->obj[0])); in gma_pipe_set_base()
146 struct drm_device *dev = crtc->dev; in gma_crtc_load_lut()
149 const struct psb_offset *map = &dev_priv->regmap[gma_crtc->pipe]; in gma_crtc_load_lut()
150 int palreg = map->palette; in gma_crtc_load_lut()
155 if (!crtc->enabled) in gma_crtc_load_lut()
158 r = crtc->gamma_store; in gma_crtc_load_lut()
159 g = r + crtc->gamma_size; in gma_crtc_load_lut()
160 b = g + crtc->gamma_size; in gma_crtc_load_lut()
165 (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) | in gma_crtc_load_lut()
166 (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) | in gma_crtc_load_lut()
167 ((*b++ >> 8) + gma_crtc->lut_adj[i])); in gma_crtc_load_lut()
172 /* FIXME: Why pipe[0] and not pipe[..._crtc->pipe]? */ in gma_crtc_load_lut()
173 dev_priv->regs.pipe[0].palette[i] = in gma_crtc_load_lut()
174 (((*r++ >> 8) + gma_crtc->lut_adj[i]) << 16) | in gma_crtc_load_lut()
175 (((*g++ >> 8) + gma_crtc->lut_adj[i]) << 8) | in gma_crtc_load_lut()
176 ((*b++ >> 8) + gma_crtc->lut_adj[i]); in gma_crtc_load_lut()
199 struct drm_device *dev = crtc->dev; in gma_crtc_dpms()
202 int pipe = gma_crtc->pipe; in gma_crtc_dpms()
203 const struct psb_offset *map = &dev_priv->regmap[pipe]; in gma_crtc_dpms()
211 dev_priv->ops->disable_sr(dev); in gma_crtc_dpms()
217 if (gma_crtc->active) in gma_crtc_dpms()
220 gma_crtc->active = true; in gma_crtc_dpms()
223 temp = REG_READ(map->dpll); in gma_crtc_dpms()
225 REG_WRITE(map->dpll, temp); in gma_crtc_dpms()
226 REG_READ(map->dpll); in gma_crtc_dpms()
229 REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); in gma_crtc_dpms()
230 REG_READ(map->dpll); in gma_crtc_dpms()
233 REG_WRITE(map->dpll, temp | DPLL_VCO_ENABLE); in gma_crtc_dpms()
234 REG_READ(map->dpll); in gma_crtc_dpms()
240 temp = REG_READ(map->cntr); in gma_crtc_dpms()
242 REG_WRITE(map->cntr, in gma_crtc_dpms()
245 REG_WRITE(map->base, REG_READ(map->base)); in gma_crtc_dpms()
251 temp = REG_READ(map->conf); in gma_crtc_dpms()
253 REG_WRITE(map->conf, temp | PIPEACONF_ENABLE); in gma_crtc_dpms()
255 temp = REG_READ(map->status); in gma_crtc_dpms()
258 REG_WRITE(map->status, temp); in gma_crtc_dpms()
259 REG_READ(map->status); in gma_crtc_dpms()
270 if (!gma_crtc->active) in gma_crtc_dpms()
273 gma_crtc->active = false; in gma_crtc_dpms()
289 temp = REG_READ(map->cntr); in gma_crtc_dpms()
291 REG_WRITE(map->cntr, in gma_crtc_dpms()
294 REG_WRITE(map->base, REG_READ(map->base)); in gma_crtc_dpms()
295 REG_READ(map->base); in gma_crtc_dpms()
299 temp = REG_READ(map->conf); in gma_crtc_dpms()
301 REG_WRITE(map->conf, temp & ~PIPEACONF_ENABLE); in gma_crtc_dpms()
302 REG_READ(map->conf); in gma_crtc_dpms()
311 temp = REG_READ(map->dpll); in gma_crtc_dpms()
313 REG_WRITE(map->dpll, temp & ~DPLL_VCO_ENABLE); in gma_crtc_dpms()
314 REG_READ(map->dpll); in gma_crtc_dpms()
323 dev_priv->ops->update_wm(dev, crtc); in gma_crtc_dpms()
333 struct drm_device *dev = crtc->dev; in gma_crtc_cursor_set()
336 int pipe = gma_crtc->pipe; in gma_crtc_cursor_set()
342 struct psb_gem_object *cursor_pobj = gma_crtc->cursor_pobj; in gma_crtc_cursor_set()
357 if (gma_crtc->cursor_obj) { in gma_crtc_cursor_set()
358 pobj = to_psb_gem_object(gma_crtc->cursor_obj); in gma_crtc_cursor_set()
360 drm_gem_object_put(gma_crtc->cursor_obj); in gma_crtc_cursor_set()
361 gma_crtc->cursor_obj = NULL; in gma_crtc_cursor_set()
368 dev_dbg(dev->dev, "We currently only support 64x64 cursors\n"); in gma_crtc_cursor_set()
369 return -EINVAL; in gma_crtc_cursor_set()
374 ret = -ENOENT; in gma_crtc_cursor_set()
378 if (obj->size < width * height * 4) { in gma_crtc_cursor_set()
379 dev_dbg(dev->dev, "Buffer is too small\n"); in gma_crtc_cursor_set()
380 ret = -ENOMEM; in gma_crtc_cursor_set()
389 dev_err(dev->dev, "Can not pin down handle 0x%x\n", handle); in gma_crtc_cursor_set()
393 if (dev_priv->ops->cursor_needs_phys) { in gma_crtc_cursor_set()
395 dev_err(dev->dev, "No hardware cursor mem available"); in gma_crtc_cursor_set()
396 ret = -ENOMEM; in gma_crtc_cursor_set()
400 cursor_pages = obj->size / PAGE_SIZE; in gma_crtc_cursor_set()
405 tmp_dst = dev_priv->vram_addr + cursor_pobj->offset; in gma_crtc_cursor_set()
407 memcpy_from_page(tmp_dst, pobj->pages[i], 0, PAGE_SIZE); in gma_crtc_cursor_set()
411 addr = gma_crtc->cursor_addr; in gma_crtc_cursor_set()
413 addr = pobj->offset; in gma_crtc_cursor_set()
414 gma_crtc->cursor_addr = addr; in gma_crtc_cursor_set()
429 if (gma_crtc->cursor_obj) { in gma_crtc_cursor_set()
430 pobj = to_psb_gem_object(gma_crtc->cursor_obj); in gma_crtc_cursor_set()
432 drm_gem_object_put(gma_crtc->cursor_obj); in gma_crtc_cursor_set()
435 gma_crtc->cursor_obj = obj; in gma_crtc_cursor_set()
446 struct drm_device *dev = crtc->dev; in gma_crtc_cursor_move()
448 int pipe = gma_crtc->pipe; in gma_crtc_cursor_move()
454 x = -x; in gma_crtc_cursor_move()
458 y = -y; in gma_crtc_cursor_move()
464 addr = gma_crtc->cursor_addr; in gma_crtc_cursor_move()
476 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in gma_crtc_prepare()
477 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF); in gma_crtc_prepare()
482 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in gma_crtc_commit()
483 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON); in gma_crtc_commit()
489 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in gma_crtc_disable()
491 crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF); in gma_crtc_disable()
493 if (crtc->primary->fb) { in gma_crtc_disable()
494 pobj = to_psb_gem_object(crtc->primary->fb->obj[0]); in gma_crtc_disable()
503 if (gma_crtc->cursor_pobj) in gma_crtc_destroy()
504 drm_gem_object_put(&gma_crtc->cursor_pobj->base); in gma_crtc_destroy()
506 kfree(gma_crtc->crtc_state); in gma_crtc_destroy()
518 struct drm_framebuffer *current_fb = crtc->primary->fb; in gma_crtc_page_flip()
519 struct drm_framebuffer *old_fb = crtc->primary->old_fb; in gma_crtc_page_flip()
520 const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private; in gma_crtc_page_flip()
521 struct drm_device *dev = crtc->dev; in gma_crtc_page_flip()
525 if (!crtc_funcs->mode_set_base) in gma_crtc_page_flip()
526 return -EINVAL; in gma_crtc_page_flip()
529 crtc->primary->fb = fb; in gma_crtc_page_flip()
532 spin_lock_irqsave(&dev->event_lock, flags); in gma_crtc_page_flip()
536 gma_crtc->page_flip_event = event; in gma_crtc_page_flip()
537 spin_unlock_irqrestore(&dev->event_lock, flags); in gma_crtc_page_flip()
540 ret = crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y, old_fb); in gma_crtc_page_flip()
542 spin_lock_irqsave(&dev->event_lock, flags); in gma_crtc_page_flip()
543 if (gma_crtc->page_flip_event) { in gma_crtc_page_flip()
544 gma_crtc->page_flip_event = NULL; in gma_crtc_page_flip()
547 spin_unlock_irqrestore(&dev->event_lock, flags); in gma_crtc_page_flip()
550 ret = crtc_funcs->mode_set_base(crtc, crtc->x, crtc->y, old_fb); in gma_crtc_page_flip()
555 crtc->primary->fb = current_fb; in gma_crtc_page_flip()
577 struct drm_device *dev = crtc->dev; in gma_crtc_save()
580 struct psb_intel_crtc_state *crtc_state = gma_crtc->crtc_state; in gma_crtc_save()
581 const struct psb_offset *map = &dev_priv->regmap[gma_crtc->pipe]; in gma_crtc_save()
586 dev_err(dev->dev, "No CRTC state found\n"); in gma_crtc_save()
590 crtc_state->saveDSPCNTR = REG_READ(map->cntr); in gma_crtc_save()
591 crtc_state->savePIPECONF = REG_READ(map->conf); in gma_crtc_save()
592 crtc_state->savePIPESRC = REG_READ(map->src); in gma_crtc_save()
593 crtc_state->saveFP0 = REG_READ(map->fp0); in gma_crtc_save()
594 crtc_state->saveFP1 = REG_READ(map->fp1); in gma_crtc_save()
595 crtc_state->saveDPLL = REG_READ(map->dpll); in gma_crtc_save()
596 crtc_state->saveHTOTAL = REG_READ(map->htotal); in gma_crtc_save()
597 crtc_state->saveHBLANK = REG_READ(map->hblank); in gma_crtc_save()
598 crtc_state->saveHSYNC = REG_READ(map->hsync); in gma_crtc_save()
599 crtc_state->saveVTOTAL = REG_READ(map->vtotal); in gma_crtc_save()
600 crtc_state->saveVBLANK = REG_READ(map->vblank); in gma_crtc_save()
601 crtc_state->saveVSYNC = REG_READ(map->vsync); in gma_crtc_save()
602 crtc_state->saveDSPSTRIDE = REG_READ(map->stride); in gma_crtc_save()
605 crtc_state->saveDSPSIZE = REG_READ(map->size); in gma_crtc_save()
606 crtc_state->saveDSPPOS = REG_READ(map->pos); in gma_crtc_save()
608 crtc_state->saveDSPBASE = REG_READ(map->base); in gma_crtc_save()
610 palette_reg = map->palette; in gma_crtc_save()
612 crtc_state->savePalette[i] = REG_READ(palette_reg + (i << 2)); in gma_crtc_save()
620 struct drm_device *dev = crtc->dev; in gma_crtc_restore()
623 struct psb_intel_crtc_state *crtc_state = gma_crtc->crtc_state; in gma_crtc_restore()
624 const struct psb_offset *map = &dev_priv->regmap[gma_crtc->pipe]; in gma_crtc_restore()
629 dev_err(dev->dev, "No crtc state\n"); in gma_crtc_restore()
633 if (crtc_state->saveDPLL & DPLL_VCO_ENABLE) { in gma_crtc_restore()
634 REG_WRITE(map->dpll, in gma_crtc_restore()
635 crtc_state->saveDPLL & ~DPLL_VCO_ENABLE); in gma_crtc_restore()
636 REG_READ(map->dpll); in gma_crtc_restore()
640 REG_WRITE(map->fp0, crtc_state->saveFP0); in gma_crtc_restore()
641 REG_READ(map->fp0); in gma_crtc_restore()
643 REG_WRITE(map->fp1, crtc_state->saveFP1); in gma_crtc_restore()
644 REG_READ(map->fp1); in gma_crtc_restore()
646 REG_WRITE(map->dpll, crtc_state->saveDPLL); in gma_crtc_restore()
647 REG_READ(map->dpll); in gma_crtc_restore()
650 REG_WRITE(map->htotal, crtc_state->saveHTOTAL); in gma_crtc_restore()
651 REG_WRITE(map->hblank, crtc_state->saveHBLANK); in gma_crtc_restore()
652 REG_WRITE(map->hsync, crtc_state->saveHSYNC); in gma_crtc_restore()
653 REG_WRITE(map->vtotal, crtc_state->saveVTOTAL); in gma_crtc_restore()
654 REG_WRITE(map->vblank, crtc_state->saveVBLANK); in gma_crtc_restore()
655 REG_WRITE(map->vsync, crtc_state->saveVSYNC); in gma_crtc_restore()
656 REG_WRITE(map->stride, crtc_state->saveDSPSTRIDE); in gma_crtc_restore()
658 REG_WRITE(map->size, crtc_state->saveDSPSIZE); in gma_crtc_restore()
659 REG_WRITE(map->pos, crtc_state->saveDSPPOS); in gma_crtc_restore()
661 REG_WRITE(map->src, crtc_state->savePIPESRC); in gma_crtc_restore()
662 REG_WRITE(map->base, crtc_state->saveDSPBASE); in gma_crtc_restore()
663 REG_WRITE(map->conf, crtc_state->savePIPECONF); in gma_crtc_restore()
667 REG_WRITE(map->cntr, crtc_state->saveDSPCNTR); in gma_crtc_restore()
668 REG_WRITE(map->base, crtc_state->saveDSPBASE); in gma_crtc_restore()
672 palette_reg = map->palette; in gma_crtc_restore()
674 REG_WRITE(palette_reg + (i << 2), crtc_state->savePalette[i]); in gma_crtc_restore()
680 encoder->helper_private; in gma_encoder_prepare()
682 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_OFF); in gma_encoder_prepare()
688 encoder->helper_private; in gma_encoder_commit()
690 encoder_funcs->dpms(encoder, DRM_MODE_DPMS_ON); in gma_encoder_commit()
706 return &gma_encoder->base; in gma_best_encoder()
712 connector->encoder = encoder; in gma_connector_attach_encoder()
713 drm_connector_attach_encoder(&connector->base, in gma_connector_attach_encoder()
714 &encoder->base); in gma_connector_attach_encoder()
723 if (clock->p1 < limit->p1.min || limit->p1.max < clock->p1) in gma_pll_is_valid()
725 if (clock->p < limit->p.min || limit->p.max < clock->p) in gma_pll_is_valid()
727 if (clock->m2 < limit->m2.min || limit->m2.max < clock->m2) in gma_pll_is_valid()
729 if (clock->m1 < limit->m1.min || limit->m1.max < clock->m1) in gma_pll_is_valid()
732 if (clock->m1 <= clock->m2 && clock->m1 != 0) in gma_pll_is_valid()
734 if (clock->m < limit->m.min || limit->m.max < clock->m) in gma_pll_is_valid()
736 if (clock->n < limit->n.min || limit->n.max < clock->n) in gma_pll_is_valid()
738 if (clock->vco < limit->vco.min || limit->vco.max < clock->vco) in gma_pll_is_valid()
739 GMA_PLL_INVALID("vco out of range"); in gma_pll_is_valid()
744 if (clock->dot < limit->dot.min || limit->dot.max < clock->dot) in gma_pll_is_valid()
754 struct drm_device *dev = crtc->dev; in gma_find_best_pll()
756 to_gma_crtc(crtc)->clock_funcs; in gma_find_best_pll()
764 * settings for dual-channel. We haven't figured out how to in gma_find_best_pll()
770 clock.p2 = limit->p2.p2_fast; in gma_find_best_pll()
772 clock.p2 = limit->p2.p2_slow; in gma_find_best_pll()
774 if (target < limit->p2.dot_limit) in gma_find_best_pll()
775 clock.p2 = limit->p2.p2_slow; in gma_find_best_pll()
777 clock.p2 = limit->p2.p2_fast; in gma_find_best_pll()
783 for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max; clock.m1++) { in gma_find_best_pll()
784 for (clock.m2 = limit->m2.min; in gma_find_best_pll()
786 clock.m2 <= limit->m2.max; clock.m2++) { in gma_find_best_pll()
787 for (clock.n = limit->n.min; in gma_find_best_pll()
788 clock.n <= limit->n.max; clock.n++) { in gma_find_best_pll()
789 for (clock.p1 = limit->p1.min; in gma_find_best_pll()
790 clock.p1 <= limit->p1.max; in gma_find_best_pll()
794 clock_funcs->clock(refclk, &clock); in gma_find_best_pll()
796 if (!clock_funcs->pll_is_valid(crtc, in gma_find_best_pll()
800 this_err = abs(clock.dot - target); in gma_find_best_pll()