18 #include <linux/i2c.h>
44 #define MRST_LIMIT_LVDS_100L 0
45 #define MRST_LIMIT_LVDS_83 1
46 #define MRST_LIMIT_LVDS_100 2
48 #define MRST_DOT_MIN 19750
49 #define MRST_DOT_MAX 120000
50 #define MRST_M_MIN_100L 20
51 #define MRST_M_MIN_100 10
52 #define MRST_M_MIN_83 12
53 #define MRST_M_MAX_100L 34
54 #define MRST_M_MAX_100 17
55 #define MRST_M_MAX_83 20
57 #define MRST_P1_MAX_0 7
58 #define MRST_P1_MAX_1 8
79 static const u32 oaktrail_m_converts[] = {
80 0x2B, 0x15, 0x2A, 0x35, 0x1A, 0x0D, 0x26, 0x33, 0x19, 0x2C,
81 0x36, 0x3B, 0x1D, 0x2E, 0x37, 0x1B, 0x2D, 0x16, 0x0B, 0x25,
82 0x12, 0x09, 0x24, 0x32, 0x39, 0x1c,
106 dev_err(dev->dev,
"oaktrail_limit Wrong display type.\n");
115 clock->
dot = (refclk * clock->
m) / (14 * clock->
p1);
120 pr_debug(
"%s: dotclock = %d, m = %d, p1 = %d.\n",
121 prefix, clock->
dot, clock->
m, clock->
p1);
136 memset(best_clock, 0,
sizeof(*best_clock));
138 for (clock.
m = limit->m.min; clock.
m <= limit->m.max; clock.
m++) {
139 for (clock.
p1 = limit->
p1.min; clock.
p1 <= limit->
p1.max;
143 oaktrail_clock(refclk, &clock);
145 this_err =
abs(clock.
dot - target);
146 if (this_err < err) {
152 dev_dbg(crtc->
dev->dev,
"mrstFindBestPLL err = %d.\n", err);
162 static void oaktrail_crtc_dpms(
struct drm_crtc *crtc,
int mode)
205 temp | DISPLAY_PLANE_ENABLE);
225 if ((temp & DISPLAY_PLANE_ENABLE) != 0) {
227 temp & ~DISPLAY_PLANE_ENABLE);
235 if ((temp & PIPEACONF_ENABLE) != 0) {
243 if ((temp & DPLL_VCO_ENABLE) != 0) {
271 static int oaktrail_panel_fitter_pipe(
struct drm_device *dev)
280 return (pfit_control >> 29) & 3;
283 static int oaktrail_crtc_mode_set(
struct drm_crtc *crtc,
292 int pipe = psb_intel_crtc->
pipe;
296 u32 dpll = 0,
fp = 0, dspcntr, pipeconf;
297 bool ok, is_sdvo =
false;
298 bool is_lvds =
false;
299 bool is_mipi =
false;
319 psb_intel_encoder = psb_intel_attached_encoder(connector);
321 switch (psb_intel_encoder->
type) {
338 if (oaktrail_panel_fitter_pipe(dev) == pipe)
345 if (psb_intel_encoder)
347 dev->mode_config.scaling_mode_property, &scalingType);
353 int offsetX = 0, offsetY = 0;
411 goto oaktrail_crtc_mode_set_exit;
417 ok = mrstFindBestPLL(crtc, adjusted_mode->
clock, refclk, &clock);
420 dev_dbg(dev->dev,
"mrstFindBestPLL fail in oaktrail_crtc_mode_set.\n");
422 dev_dbg(dev->dev,
"oaktrail_crtc_mode_set pixel clock = %d,"
423 "m = %x, p1 = %x.\n", clock.
dot, clock.
m,
440 int sdvo_pixel_multiply =
445 (sdvo_pixel_multiply -
451 dpll |= (1 << (clock.
p1 - 2)) << 17;
455 mrstPrintPll(
"chosen", &clock);
457 if (dpll & DPLL_VCO_ENABLE) {
484 oaktrail_crtc_mode_set_exit:
489 static bool oaktrail_crtc_mode_fixup(
struct drm_crtc *crtc,
496 static int oaktrail_pipe_set_base(
struct drm_crtc *crtc,
503 int pipe = psb_intel_crtc->
pipe;
512 dev_dbg(dev->dev,
"No FB bound\n");
519 start = psbfb->
gtt->offset;
520 offset = y * crtc->
fb->pitches[0] + x * (crtc->
fb->bits_per_pixel / 8);
527 switch (crtc->
fb->bits_per_pixel) {
532 if (crtc->
fb->depth == 15)
542 dev_err(dev->dev,
"Unknown color depth\n");
544 goto pipe_set_base_exit;
558 static void oaktrail_crtc_prepare(
struct drm_crtc *crtc)
564 static void oaktrail_crtc_commit(
struct drm_crtc *crtc)
571 .dpms = oaktrail_crtc_dpms,
572 .mode_fixup = oaktrail_crtc_mode_fixup,
573 .mode_set = oaktrail_crtc_mode_set,
574 .mode_set_base = oaktrail_pipe_set_base,
575 .prepare = oaktrail_crtc_prepare,
576 .commit = oaktrail_crtc_commit,