Commit 16844fb1 authored by Rahul Sharma's avatar Rahul Sharma Committed by Inki Dae

drm/exynos: hdmi: use drm_display_mode to check the supported modes

This patch renames check_timing to check_mode and removes the
unnecessary conversion of drm_display_mode to/from fb_videomode in
the hdmi driver.

v4:
1) Changed the commit message to add information related to renaming
the callbacks to check_mode.
2) Changed debug message to print 1/0 for interlace mode.

v3:
1) Replaced check_timing callbacks with check_mode.
2) Change the type of second parameter of check_mode callback from void
pointer paramenter to struct drm_display_mode pointer.

v2:
1) Removed convert_to_video_timing().
2) Corrected DRM_DEBUG_KMS to print the resolution properly.
Signed-off-by: default avatarRahul Sharma <rahul.sharma@samsung.com>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent 725ddead
...@@ -58,37 +58,6 @@ convert_to_display_mode(struct drm_display_mode *mode, ...@@ -58,37 +58,6 @@ convert_to_display_mode(struct drm_display_mode *mode,
mode->flags |= DRM_MODE_FLAG_DBLSCAN; mode->flags |= DRM_MODE_FLAG_DBLSCAN;
} }
/* convert drm_display_mode to exynos_video_timings */
static inline void
convert_to_video_timing(struct fb_videomode *timing,
struct drm_display_mode *mode)
{
DRM_DEBUG_KMS("%s\n", __FILE__);
memset(timing, 0, sizeof(*timing));
timing->pixclock = mode->clock * 1000;
timing->refresh = drm_mode_vrefresh(mode);
timing->xres = mode->hdisplay;
timing->right_margin = mode->hsync_start - mode->hdisplay;
timing->hsync_len = mode->hsync_end - mode->hsync_start;
timing->left_margin = mode->htotal - mode->hsync_end;
timing->yres = mode->vdisplay;
timing->lower_margin = mode->vsync_start - mode->vdisplay;
timing->vsync_len = mode->vsync_end - mode->vsync_start;
timing->upper_margin = mode->vtotal - mode->vsync_end;
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
timing->vmode = FB_VMODE_INTERLACED;
else
timing->vmode = FB_VMODE_NONINTERLACED;
if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
timing->vmode |= FB_VMODE_DOUBLE;
}
static int exynos_drm_connector_get_modes(struct drm_connector *connector) static int exynos_drm_connector_get_modes(struct drm_connector *connector)
{ {
struct exynos_drm_connector *exynos_connector = struct exynos_drm_connector *exynos_connector =
...@@ -168,15 +137,12 @@ static int exynos_drm_connector_mode_valid(struct drm_connector *connector, ...@@ -168,15 +137,12 @@ static int exynos_drm_connector_mode_valid(struct drm_connector *connector,
to_exynos_connector(connector); to_exynos_connector(connector);
struct exynos_drm_manager *manager = exynos_connector->manager; struct exynos_drm_manager *manager = exynos_connector->manager;
struct exynos_drm_display_ops *display_ops = manager->display_ops; struct exynos_drm_display_ops *display_ops = manager->display_ops;
struct fb_videomode timing;
int ret = MODE_BAD; int ret = MODE_BAD;
DRM_DEBUG_KMS("%s\n", __FILE__); DRM_DEBUG_KMS("%s\n", __FILE__);
convert_to_video_timing(&timing, mode); if (display_ops && display_ops->check_mode)
if (!display_ops->check_mode(manager->dev, mode))
if (display_ops && display_ops->check_timing)
if (!display_ops->check_timing(manager->dev, (void *)&timing))
ret = MODE_OK; ret = MODE_OK;
return ret; return ret;
......
...@@ -142,7 +142,7 @@ struct exynos_drm_overlay { ...@@ -142,7 +142,7 @@ struct exynos_drm_overlay {
* @is_connected: check for that display is connected or not. * @is_connected: check for that display is connected or not.
* @get_edid: get edid modes from display driver. * @get_edid: get edid modes from display driver.
* @get_panel: get panel object from display driver. * @get_panel: get panel object from display driver.
* @check_timing: check if timing is valid or not. * @check_mode: check if mode is valid or not.
* @power_on: display device on or off. * @power_on: display device on or off.
*/ */
struct exynos_drm_display_ops { struct exynos_drm_display_ops {
...@@ -151,7 +151,7 @@ struct exynos_drm_display_ops { ...@@ -151,7 +151,7 @@ struct exynos_drm_display_ops {
struct edid *(*get_edid)(struct device *dev, struct edid *(*get_edid)(struct device *dev,
struct drm_connector *connector); struct drm_connector *connector);
void *(*get_panel)(struct device *dev); void *(*get_panel)(struct device *dev);
int (*check_timing)(struct device *dev, void *timing); int (*check_mode)(struct device *dev, struct drm_display_mode *mode);
int (*power_on)(struct device *dev, int mode); int (*power_on)(struct device *dev, int mode);
}; };
......
...@@ -166,7 +166,7 @@ static void *fimd_get_panel(struct device *dev) ...@@ -166,7 +166,7 @@ static void *fimd_get_panel(struct device *dev)
return ctx->panel; return ctx->panel;
} }
static int fimd_check_timing(struct device *dev, void *timing) static int fimd_check_mode(struct device *dev, struct drm_display_mode *mode)
{ {
DRM_DEBUG_KMS("%s\n", __FILE__); DRM_DEBUG_KMS("%s\n", __FILE__);
...@@ -188,7 +188,7 @@ static struct exynos_drm_display_ops fimd_display_ops = { ...@@ -188,7 +188,7 @@ static struct exynos_drm_display_ops fimd_display_ops = {
.type = EXYNOS_DISPLAY_TYPE_LCD, .type = EXYNOS_DISPLAY_TYPE_LCD,
.is_connected = fimd_display_is_connected, .is_connected = fimd_display_is_connected,
.get_panel = fimd_get_panel, .get_panel = fimd_get_panel,
.check_timing = fimd_check_timing, .check_mode = fimd_check_mode,
.power_on = fimd_display_power_on, .power_on = fimd_display_power_on,
}; };
......
...@@ -127,7 +127,8 @@ static struct edid *drm_hdmi_get_edid(struct device *dev, ...@@ -127,7 +127,8 @@ static struct edid *drm_hdmi_get_edid(struct device *dev,
return NULL; return NULL;
} }
static int drm_hdmi_check_timing(struct device *dev, void *timing) static int drm_hdmi_check_mode(struct device *dev,
struct drm_display_mode *mode)
{ {
struct drm_hdmi_context *ctx = to_context(dev); struct drm_hdmi_context *ctx = to_context(dev);
int ret = 0; int ret = 0;
...@@ -139,14 +140,14 @@ static int drm_hdmi_check_timing(struct device *dev, void *timing) ...@@ -139,14 +140,14 @@ static int drm_hdmi_check_timing(struct device *dev, void *timing)
* If any of the two fails, return mode as BAD. * If any of the two fails, return mode as BAD.
*/ */
if (mixer_ops && mixer_ops->check_timing) if (mixer_ops && mixer_ops->check_mode)
ret = mixer_ops->check_timing(ctx->mixer_ctx->ctx, timing); ret = mixer_ops->check_mode(ctx->mixer_ctx->ctx, mode);
if (ret) if (ret)
return ret; return ret;
if (hdmi_ops && hdmi_ops->check_timing) if (hdmi_ops && hdmi_ops->check_mode)
return hdmi_ops->check_timing(ctx->hdmi_ctx->ctx, timing); return hdmi_ops->check_mode(ctx->hdmi_ctx->ctx, mode);
return 0; return 0;
} }
...@@ -167,7 +168,7 @@ static struct exynos_drm_display_ops drm_hdmi_display_ops = { ...@@ -167,7 +168,7 @@ static struct exynos_drm_display_ops drm_hdmi_display_ops = {
.type = EXYNOS_DISPLAY_TYPE_HDMI, .type = EXYNOS_DISPLAY_TYPE_HDMI,
.is_connected = drm_hdmi_is_connected, .is_connected = drm_hdmi_is_connected,
.get_edid = drm_hdmi_get_edid, .get_edid = drm_hdmi_get_edid,
.check_timing = drm_hdmi_check_timing, .check_mode = drm_hdmi_check_mode,
.power_on = drm_hdmi_power_on, .power_on = drm_hdmi_power_on,
}; };
...@@ -218,7 +219,7 @@ static void drm_hdmi_mode_fixup(struct device *subdrv_dev, ...@@ -218,7 +219,7 @@ static void drm_hdmi_mode_fixup(struct device *subdrv_dev,
drm_mode_set_crtcinfo(adjusted_mode, 0); drm_mode_set_crtcinfo(adjusted_mode, 0);
mode_ok = drm_hdmi_check_timing(subdrv_dev, adjusted_mode); mode_ok = drm_hdmi_check_mode(subdrv_dev, adjusted_mode);
/* just return if user desired mode exists. */ /* just return if user desired mode exists. */
if (mode_ok == 0) if (mode_ok == 0)
...@@ -229,7 +230,7 @@ static void drm_hdmi_mode_fixup(struct device *subdrv_dev, ...@@ -229,7 +230,7 @@ static void drm_hdmi_mode_fixup(struct device *subdrv_dev,
* to adjusted_mode. * to adjusted_mode.
*/ */
list_for_each_entry(m, &connector->modes, head) { list_for_each_entry(m, &connector->modes, head) {
mode_ok = drm_hdmi_check_timing(subdrv_dev, m); mode_ok = drm_hdmi_check_mode(subdrv_dev, m);
if (mode_ok == 0) { if (mode_ok == 0) {
struct drm_mode_object base; struct drm_mode_object base;
......
...@@ -32,11 +32,11 @@ struct exynos_hdmi_ops { ...@@ -32,11 +32,11 @@ struct exynos_hdmi_ops {
bool (*is_connected)(void *ctx); bool (*is_connected)(void *ctx);
struct edid *(*get_edid)(void *ctx, struct edid *(*get_edid)(void *ctx,
struct drm_connector *connector); struct drm_connector *connector);
int (*check_timing)(void *ctx, struct fb_videomode *timing); int (*check_mode)(void *ctx, struct drm_display_mode *mode);
int (*power_on)(void *ctx, int mode); int (*power_on)(void *ctx, int mode);
/* manager */ /* manager */
void (*mode_set)(void *ctx, void *mode); void (*mode_set)(void *ctx, struct drm_display_mode *mode);
void (*get_max_resol)(void *ctx, unsigned int *width, void (*get_max_resol)(void *ctx, unsigned int *width,
unsigned int *height); unsigned int *height);
void (*commit)(void *ctx); void (*commit)(void *ctx);
...@@ -57,7 +57,7 @@ struct exynos_mixer_ops { ...@@ -57,7 +57,7 @@ struct exynos_mixer_ops {
void (*win_disable)(void *ctx, int zpos); void (*win_disable)(void *ctx, int zpos);
/* display */ /* display */
int (*check_timing)(void *ctx, struct fb_videomode *timing); int (*check_mode)(void *ctx, struct drm_display_mode *mode);
}; };
void exynos_hdmi_drv_attach(struct exynos_drm_hdmi_context *ctx); void exynos_hdmi_drv_attach(struct exynos_drm_hdmi_context *ctx);
......
...@@ -135,7 +135,7 @@ static void *vidi_get_panel(struct device *dev) ...@@ -135,7 +135,7 @@ static void *vidi_get_panel(struct device *dev)
return NULL; return NULL;
} }
static int vidi_check_timing(struct device *dev, void *timing) static int vidi_check_mode(struct device *dev, struct drm_display_mode *mode)
{ {
DRM_DEBUG_KMS("%s\n", __FILE__); DRM_DEBUG_KMS("%s\n", __FILE__);
...@@ -158,7 +158,7 @@ static struct exynos_drm_display_ops vidi_display_ops = { ...@@ -158,7 +158,7 @@ static struct exynos_drm_display_ops vidi_display_ops = {
.is_connected = vidi_display_is_connected, .is_connected = vidi_display_is_connected,
.get_edid = vidi_get_edid, .get_edid = vidi_get_edid,
.get_panel = vidi_get_panel, .get_panel = vidi_get_panel,
.check_timing = vidi_check_timing, .check_mode = vidi_check_mode,
.power_on = vidi_display_power_on, .power_on = vidi_display_power_on,
}; };
......
...@@ -796,18 +796,17 @@ static int hdmi_find_phy_conf(struct hdmi_context *hdata, u32 pixel_clock) ...@@ -796,18 +796,17 @@ static int hdmi_find_phy_conf(struct hdmi_context *hdata, u32 pixel_clock)
return -EINVAL; return -EINVAL;
} }
static int hdmi_check_timing(void *ctx, struct fb_videomode *timing) static int hdmi_check_mode(void *ctx, struct drm_display_mode *mode)
{ {
struct hdmi_context *hdata = ctx; struct hdmi_context *hdata = ctx;
int ret; int ret;
DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%d clock=%d\n",
mode->hdisplay, mode->vdisplay, mode->vrefresh,
DRM_DEBUG_KMS("[%d]x[%d] [%d]Hz [%x]\n", timing->xres, (mode->flags & DRM_MODE_FLAG_INTERLACE) ? true :
timing->yres, timing->refresh, false, mode->clock * 1000);
timing->vmode);
ret = hdmi_find_phy_conf(hdata, timing->pixclock); ret = hdmi_find_phy_conf(hdata, mode->clock * 1000);
if (ret < 0) if (ret < 0)
return ret; return ret;
return 0; return 0;
...@@ -1042,7 +1041,7 @@ static void hdmi_conf_init(struct hdmi_context *hdata) ...@@ -1042,7 +1041,7 @@ static void hdmi_conf_init(struct hdmi_context *hdata)
} }
} }
static void hdmi_v13_timing_apply(struct hdmi_context *hdata) static void hdmi_v13_mode_apply(struct hdmi_context *hdata)
{ {
const struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v13_conf.tg; const struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v13_conf.tg;
const struct hdmi_v13_core_regs *core = const struct hdmi_v13_core_regs *core =
...@@ -1131,7 +1130,7 @@ static void hdmi_v13_timing_apply(struct hdmi_context *hdata) ...@@ -1131,7 +1130,7 @@ static void hdmi_v13_timing_apply(struct hdmi_context *hdata)
hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN); hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN);
} }
static void hdmi_v14_timing_apply(struct hdmi_context *hdata) static void hdmi_v14_mode_apply(struct hdmi_context *hdata)
{ {
const struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v14_conf.tg; const struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v14_conf.tg;
const struct hdmi_v14_core_regs *core = const struct hdmi_v14_core_regs *core =
...@@ -1298,12 +1297,12 @@ static void hdmi_v14_timing_apply(struct hdmi_context *hdata) ...@@ -1298,12 +1297,12 @@ static void hdmi_v14_timing_apply(struct hdmi_context *hdata)
hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN); hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN);
} }
static void hdmi_timing_apply(struct hdmi_context *hdata) static void hdmi_mode_apply(struct hdmi_context *hdata)
{ {
if (hdata->type == HDMI_TYPE13) if (hdata->type == HDMI_TYPE13)
hdmi_v13_timing_apply(hdata); hdmi_v13_mode_apply(hdata);
else else
hdmi_v14_timing_apply(hdata); hdmi_v14_mode_apply(hdata);
} }
static void hdmiphy_conf_reset(struct hdmi_context *hdata) static void hdmiphy_conf_reset(struct hdmi_context *hdata)
...@@ -1423,7 +1422,7 @@ static void hdmi_conf_apply(struct hdmi_context *hdata) ...@@ -1423,7 +1422,7 @@ static void hdmi_conf_apply(struct hdmi_context *hdata)
hdmi_audio_init(hdata); hdmi_audio_init(hdata);
/* setting core registers */ /* setting core registers */
hdmi_timing_apply(hdata); hdmi_mode_apply(hdata);
hdmi_audio_control(hdata, true); hdmi_audio_control(hdata, true);
hdmi_regs_dump(hdata, "start"); hdmi_regs_dump(hdata, "start");
...@@ -1642,7 +1641,7 @@ static void hdmi_v14_mode_set(struct hdmi_context *hdata, ...@@ -1642,7 +1641,7 @@ static void hdmi_v14_mode_set(struct hdmi_context *hdata,
hdmi_set_reg(tg->tg_3d, 1, 0x0); hdmi_set_reg(tg->tg_3d, 1, 0x0);
} }
static void hdmi_mode_set(void *ctx, void *mode) static void hdmi_mode_set(void *ctx, struct drm_display_mode *mode)
{ {
struct hdmi_context *hdata = ctx; struct hdmi_context *hdata = ctx;
struct drm_display_mode *m = mode; struct drm_display_mode *m = mode;
...@@ -1767,7 +1766,7 @@ static struct exynos_hdmi_ops hdmi_ops = { ...@@ -1767,7 +1766,7 @@ static struct exynos_hdmi_ops hdmi_ops = {
/* display */ /* display */
.is_connected = hdmi_is_connected, .is_connected = hdmi_is_connected,
.get_edid = hdmi_get_edid, .get_edid = hdmi_get_edid,
.check_timing = hdmi_check_timing, .check_mode = hdmi_check_mode,
/* manager */ /* manager */
.mode_set = hdmi_mode_set, .mode_set = hdmi_mode_set,
......
...@@ -820,17 +820,16 @@ static void mixer_win_disable(void *ctx, int win) ...@@ -820,17 +820,16 @@ static void mixer_win_disable(void *ctx, int win)
mixer_ctx->win_data[win].enabled = false; mixer_ctx->win_data[win].enabled = false;
} }
static int mixer_check_timing(void *ctx, struct fb_videomode *timing) static int mixer_check_mode(void *ctx, struct drm_display_mode *mode)
{ {
u32 w, h; u32 w, h;
w = timing->xres; w = mode->hdisplay;
h = timing->yres; h = mode->vdisplay;
DRM_DEBUG_KMS("%s : xres=%d, yres=%d, refresh=%d, intl=%d\n", DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%d\n",
__func__, timing->xres, timing->yres, mode->hdisplay, mode->vdisplay, mode->vrefresh,
timing->refresh, (timing->vmode & (mode->flags & DRM_MODE_FLAG_INTERLACE) ? 1 : 0);
FB_VMODE_INTERLACED) ? true : false);
if ((w >= 464 && w <= 720 && h >= 261 && h <= 576) || if ((w >= 464 && w <= 720 && h >= 261 && h <= 576) ||
(w >= 1024 && w <= 1280 && h >= 576 && h <= 720) || (w >= 1024 && w <= 1280 && h >= 576 && h <= 720) ||
...@@ -978,7 +977,7 @@ static struct exynos_mixer_ops mixer_ops = { ...@@ -978,7 +977,7 @@ static struct exynos_mixer_ops mixer_ops = {
.win_disable = mixer_win_disable, .win_disable = mixer_win_disable,
/* display */ /* display */
.check_timing = mixer_check_timing, .check_mode = mixer_check_mode,
}; };
static irqreturn_t mixer_irq_handler(int irq, void *arg) static irqreturn_t mixer_irq_handler(int irq, void *arg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment