Commit 53aa37fb authored by Dave Airlie's avatar Dave Airlie

Merge tag 'imx-drm-next-2020-10-30' of git://git.pengutronix.de/git/pza/linux into drm-fixes

drm/imx: fixes and cleanups

Remove unused functions and empty callbacks, let the dw_hdmi-imx driver
reuse imx_drm_encoder_parse_of() instead of reimplementing it, replace
the custom register spinlock with the regmap default spinlock and remove
redundant tracking of enabled state in imx-tve, drop the explicit
drm_mode_config_cleanup() call in imx-drm-core, reduce the scope of edid
length variables that are not otherwise used in imx-ldb and
parallel-display, fix a memory leak in the parallel-display bind error
path, and drop an extraneous type qualifier from of_get_tve_mode().
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/7e4af582027bbec269364b95f6978d061b48271a.camel@pengutronix.de
parents 3cea11cd 36fba366
...@@ -111,10 +111,6 @@ static int dw_hdmi_imx_parse_dt(struct imx_hdmi *hdmi) ...@@ -111,10 +111,6 @@ static int dw_hdmi_imx_parse_dt(struct imx_hdmi *hdmi)
return 0; return 0;
} }
static void dw_hdmi_imx_encoder_disable(struct drm_encoder *encoder)
{
}
static void dw_hdmi_imx_encoder_enable(struct drm_encoder *encoder) static void dw_hdmi_imx_encoder_enable(struct drm_encoder *encoder)
{ {
struct imx_hdmi *hdmi = enc_to_imx_hdmi(encoder); struct imx_hdmi *hdmi = enc_to_imx_hdmi(encoder);
...@@ -140,7 +136,6 @@ static int dw_hdmi_imx_atomic_check(struct drm_encoder *encoder, ...@@ -140,7 +136,6 @@ static int dw_hdmi_imx_atomic_check(struct drm_encoder *encoder,
static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = { static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = {
.enable = dw_hdmi_imx_encoder_enable, .enable = dw_hdmi_imx_encoder_enable,
.disable = dw_hdmi_imx_encoder_disable,
.atomic_check = dw_hdmi_imx_atomic_check, .atomic_check = dw_hdmi_imx_atomic_check,
}; };
...@@ -219,15 +214,9 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master, ...@@ -219,15 +214,9 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master,
hdmi->dev = &pdev->dev; hdmi->dev = &pdev->dev;
encoder = &hdmi->encoder; encoder = &hdmi->encoder;
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node); ret = imx_drm_encoder_parse_of(drm, encoder, dev->of_node);
/* if (ret)
* If we failed to find the CRTC(s) which this encoder is return ret;
* supposed to be connected to, it's because the CRTC has
* not been registered yet. Defer probing, and hope that
* the required CRTC is added later.
*/
if (encoder->possible_crtcs == 0)
return -EPROBE_DEFER;
ret = dw_hdmi_imx_parse_dt(hdmi); ret = dw_hdmi_imx_parse_dt(hdmi);
if (ret < 0) if (ret < 0)
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <drm/drm_fb_helper.h> #include <drm/drm_fb_helper.h>
#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_managed.h>
#include <drm/drm_of.h> #include <drm/drm_of.h>
#include <drm/drm_plane_helper.h> #include <drm/drm_plane_helper.h>
#include <drm/drm_probe_helper.h> #include <drm/drm_probe_helper.h>
...@@ -212,7 +213,9 @@ static int imx_drm_bind(struct device *dev) ...@@ -212,7 +213,9 @@ static int imx_drm_bind(struct device *dev)
drm->mode_config.allow_fb_modifiers = true; drm->mode_config.allow_fb_modifiers = true;
drm->mode_config.normalize_zpos = true; drm->mode_config.normalize_zpos = true;
drm_mode_config_init(drm); ret = drmm_mode_config_init(drm);
if (ret)
return ret;
ret = drm_vblank_init(drm, MAX_CRTC); ret = drm_vblank_init(drm, MAX_CRTC);
if (ret) if (ret)
...@@ -251,7 +254,6 @@ static int imx_drm_bind(struct device *dev) ...@@ -251,7 +254,6 @@ static int imx_drm_bind(struct device *dev)
drm_kms_helper_poll_fini(drm); drm_kms_helper_poll_fini(drm);
component_unbind_all(drm->dev, drm); component_unbind_all(drm->dev, drm);
err_kms: err_kms:
drm_mode_config_cleanup(drm);
drm_dev_put(drm); drm_dev_put(drm);
return ret; return ret;
...@@ -267,11 +269,9 @@ static void imx_drm_unbind(struct device *dev) ...@@ -267,11 +269,9 @@ static void imx_drm_unbind(struct device *dev)
component_unbind_all(drm->dev, drm); component_unbind_all(drm->dev, drm);
drm_mode_config_cleanup(drm); drm_dev_put(drm);
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
drm_dev_put(drm);
} }
static const struct component_master_ops imx_drm_ops = { static const struct component_master_ops imx_drm_ops = {
......
...@@ -62,7 +62,6 @@ struct imx_ldb_channel { ...@@ -62,7 +62,6 @@ struct imx_ldb_channel {
struct i2c_adapter *ddc; struct i2c_adapter *ddc;
int chno; int chno;
void *edid; void *edid;
int edid_len;
struct drm_display_mode mode; struct drm_display_mode mode;
int mode_valid; int mode_valid;
u32 bus_format; u32 bus_format;
...@@ -536,15 +535,14 @@ static int imx_ldb_panel_ddc(struct device *dev, ...@@ -536,15 +535,14 @@ static int imx_ldb_panel_ddc(struct device *dev,
} }
if (!channel->ddc) { if (!channel->ddc) {
int edid_len;
/* if no DDC available, fallback to hardcoded EDID */ /* if no DDC available, fallback to hardcoded EDID */
dev_dbg(dev, "no ddc available\n"); dev_dbg(dev, "no ddc available\n");
edidp = of_get_property(child, "edid", edidp = of_get_property(child, "edid", &edid_len);
&channel->edid_len);
if (edidp) { if (edidp) {
channel->edid = kmemdup(edidp, channel->edid = kmemdup(edidp, edid_len, GFP_KERNEL);
channel->edid_len,
GFP_KERNEL);
} else if (!channel->panel) { } else if (!channel->panel) {
/* fallback to display-timings node */ /* fallback to display-timings node */
ret = of_get_drm_display_mode(child, ret = of_get_drm_display_mode(child,
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/spinlock.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <video/imx-ipu-v3.h> #include <video/imx-ipu-v3.h>
...@@ -104,8 +103,6 @@ struct imx_tve { ...@@ -104,8 +103,6 @@ struct imx_tve {
struct drm_connector connector; struct drm_connector connector;
struct drm_encoder encoder; struct drm_encoder encoder;
struct device *dev; struct device *dev;
spinlock_t lock; /* register lock */
bool enabled;
int mode; int mode;
int di_hsync_pin; int di_hsync_pin;
int di_vsync_pin; int di_vsync_pin;
...@@ -129,30 +126,10 @@ static inline struct imx_tve *enc_to_tve(struct drm_encoder *e) ...@@ -129,30 +126,10 @@ static inline struct imx_tve *enc_to_tve(struct drm_encoder *e)
return container_of(e, struct imx_tve, encoder); return container_of(e, struct imx_tve, encoder);
} }
static void tve_lock(void *__tve)
__acquires(&tve->lock)
{
struct imx_tve *tve = __tve;
spin_lock(&tve->lock);
}
static void tve_unlock(void *__tve)
__releases(&tve->lock)
{
struct imx_tve *tve = __tve;
spin_unlock(&tve->lock);
}
static void tve_enable(struct imx_tve *tve) static void tve_enable(struct imx_tve *tve)
{ {
if (!tve->enabled) { clk_prepare_enable(tve->clk);
tve->enabled = true; regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, TVE_EN);
clk_prepare_enable(tve->clk);
regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,
TVE_EN, TVE_EN);
}
/* clear interrupt status register */ /* clear interrupt status register */
regmap_write(tve->regmap, TVE_STAT_REG, 0xffffffff); regmap_write(tve->regmap, TVE_STAT_REG, 0xffffffff);
...@@ -169,11 +146,8 @@ static void tve_enable(struct imx_tve *tve) ...@@ -169,11 +146,8 @@ static void tve_enable(struct imx_tve *tve)
static void tve_disable(struct imx_tve *tve) static void tve_disable(struct imx_tve *tve)
{ {
if (tve->enabled) { regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, 0);
tve->enabled = false; clk_disable_unprepare(tve->clk);
regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, 0);
clk_disable_unprepare(tve->clk);
}
} }
static int tve_setup_tvout(struct imx_tve *tve) static int tve_setup_tvout(struct imx_tve *tve)
...@@ -500,8 +474,7 @@ static struct regmap_config tve_regmap_config = { ...@@ -500,8 +474,7 @@ static struct regmap_config tve_regmap_config = {
.readable_reg = imx_tve_readable_reg, .readable_reg = imx_tve_readable_reg,
.lock = tve_lock, .fast_io = true,
.unlock = tve_unlock,
.max_register = 0xdc, .max_register = 0xdc,
}; };
...@@ -511,7 +484,7 @@ static const char * const imx_tve_modes[] = { ...@@ -511,7 +484,7 @@ static const char * const imx_tve_modes[] = {
[TVE_MODE_VGA] = "vga", [TVE_MODE_VGA] = "vga",
}; };
static const int of_get_tve_mode(struct device_node *np) static int of_get_tve_mode(struct device_node *np)
{ {
const char *bm; const char *bm;
int ret, i; int ret, i;
...@@ -544,7 +517,6 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data) ...@@ -544,7 +517,6 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
memset(tve, 0, sizeof(*tve)); memset(tve, 0, sizeof(*tve));
tve->dev = dev; tve->dev = dev;
spin_lock_init(&tve->lock);
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0); ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) { if (ddc_node) {
......
...@@ -28,7 +28,6 @@ struct imx_parallel_display { ...@@ -28,7 +28,6 @@ struct imx_parallel_display {
struct drm_bridge bridge; struct drm_bridge bridge;
struct device *dev; struct device *dev;
void *edid; void *edid;
int edid_len;
u32 bus_format; u32 bus_format;
u32 bus_flags; u32 bus_flags;
struct drm_display_mode mode; struct drm_display_mode mode;
...@@ -41,11 +40,6 @@ static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector *c) ...@@ -41,11 +40,6 @@ static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector *c)
return container_of(c, struct imx_parallel_display, connector); return container_of(c, struct imx_parallel_display, connector);
} }
static inline struct imx_parallel_display *enc_to_imxpd(struct drm_encoder *e)
{
return container_of(e, struct imx_parallel_display, encoder);
}
static inline struct imx_parallel_display *bridge_to_imxpd(struct drm_bridge *b) static inline struct imx_parallel_display *bridge_to_imxpd(struct drm_bridge *b)
{ {
return container_of(b, struct imx_parallel_display, bridge); return container_of(b, struct imx_parallel_display, bridge);
...@@ -310,6 +304,7 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) ...@@ -310,6 +304,7 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
const u8 *edidp; const u8 *edidp;
struct imx_parallel_display *imxpd; struct imx_parallel_display *imxpd;
int edid_len;
int ret; int ret;
u32 bus_format = 0; u32 bus_format = 0;
const char *fmt; const char *fmt;
...@@ -323,9 +318,9 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) ...@@ -323,9 +318,9 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
if (ret && ret != -ENODEV) if (ret && ret != -ENODEV)
return ret; return ret;
edidp = of_get_property(np, "edid", &imxpd->edid_len); edidp = of_get_property(np, "edid", &edid_len);
if (edidp) if (edidp)
imxpd->edid = kmemdup(edidp, imxpd->edid_len, GFP_KERNEL); imxpd->edid = devm_kmemdup(dev, edidp, edid_len, GFP_KERNEL);
ret = of_property_read_string(np, "interface-pix-fmt", &fmt); ret = of_property_read_string(np, "interface-pix-fmt", &fmt);
if (!ret) { if (!ret) {
...@@ -349,17 +344,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data) ...@@ -349,17 +344,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
return 0; return 0;
} }
static void imx_pd_unbind(struct device *dev, struct device *master,
void *data)
{
struct imx_parallel_display *imxpd = dev_get_drvdata(dev);
kfree(imxpd->edid);
}
static const struct component_ops imx_pd_ops = { static const struct component_ops imx_pd_ops = {
.bind = imx_pd_bind, .bind = imx_pd_bind,
.unbind = imx_pd_unbind,
}; };
static int imx_pd_probe(struct platform_device *pdev) static int imx_pd_probe(struct platform_device *pdev)
......
...@@ -133,73 +133,6 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat) ...@@ -133,73 +133,6 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
} }
EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace); EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace);
bool ipu_pixelformat_is_planar(u32 pixelformat)
{
switch (pixelformat) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61:
return true;
}
return false;
}
EXPORT_SYMBOL_GPL(ipu_pixelformat_is_planar);
enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
{
switch (mbus_code & 0xf000) {
case 0x1000:
return IPUV3_COLORSPACE_RGB;
case 0x2000:
return IPUV3_COLORSPACE_YUV;
default:
return IPUV3_COLORSPACE_UNKNOWN;
}
}
EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
{
switch (pixelformat) {
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_YVU420:
case V4L2_PIX_FMT_YUV422P:
case V4L2_PIX_FMT_NV12:
case V4L2_PIX_FMT_NV21:
case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61:
/*
* for the planar YUV formats, the stride passed to
* cpmem must be the stride in bytes of the Y plane.
* And all the planar YUV formats have an 8-bit
* Y component.
*/
return (8 * pixel_stride) >> 3;
case V4L2_PIX_FMT_RGB565:
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
return (16 * pixel_stride) >> 3;
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_RGB24:
return (24 * pixel_stride) >> 3;
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_RGB32:
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_XRGB32:
return (32 * pixel_stride) >> 3;
default:
break;
}
return -EINVAL;
}
EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
bool hflip, bool vflip) bool hflip, bool vflip)
{ {
......
...@@ -484,9 +484,6 @@ int ipu_smfc_set_watermark(struct ipu_smfc *smfc, u32 set_level, u32 clr_level); ...@@ -484,9 +484,6 @@ int ipu_smfc_set_watermark(struct ipu_smfc *smfc, u32 set_level, u32 clr_level);
enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc); enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat); enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat);
bool ipu_pixelformat_is_planar(u32 pixelformat);
int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees, int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
bool hflip, bool vflip); bool hflip, bool vflip);
int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode, int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,
......
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