Skip to content

Commit 53aa37f

Browse files
committed
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: Dave Airlie <airlied@redhat.com> From: Philipp Zabel <p.zabel@pengutronix.de> Link: https://patchwork.freedesktop.org/patch/msgid/7e4af582027bbec269364b95f6978d061b48271a.camel@pengutronix.de
2 parents 3cea11c + 36fba36 commit 53aa37f

7 files changed

Lines changed: 21 additions & 146 deletions

File tree

drivers/gpu/drm/imx/dw_hdmi-imx.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,6 @@ static int dw_hdmi_imx_parse_dt(struct imx_hdmi *hdmi)
111111
return 0;
112112
}
113113

114-
static void dw_hdmi_imx_encoder_disable(struct drm_encoder *encoder)
115-
{
116-
}
117-
118114
static void dw_hdmi_imx_encoder_enable(struct drm_encoder *encoder)
119115
{
120116
struct imx_hdmi *hdmi = enc_to_imx_hdmi(encoder);
@@ -140,7 +136,6 @@ static int dw_hdmi_imx_atomic_check(struct drm_encoder *encoder,
140136

141137
static const struct drm_encoder_helper_funcs dw_hdmi_imx_encoder_helper_funcs = {
142138
.enable = dw_hdmi_imx_encoder_enable,
143-
.disable = dw_hdmi_imx_encoder_disable,
144139
.atomic_check = dw_hdmi_imx_atomic_check,
145140
};
146141

@@ -219,15 +214,9 @@ static int dw_hdmi_imx_bind(struct device *dev, struct device *master,
219214
hdmi->dev = &pdev->dev;
220215
encoder = &hdmi->encoder;
221216

222-
encoder->possible_crtcs = drm_of_find_possible_crtcs(drm, dev->of_node);
223-
/*
224-
* If we failed to find the CRTC(s) which this encoder is
225-
* supposed to be connected to, it's because the CRTC has
226-
* not been registered yet. Defer probing, and hope that
227-
* the required CRTC is added later.
228-
*/
229-
if (encoder->possible_crtcs == 0)
230-
return -EPROBE_DEFER;
217+
ret = imx_drm_encoder_parse_of(drm, encoder, dev->of_node);
218+
if (ret)
219+
return ret;
231220

232221
ret = dw_hdmi_imx_parse_dt(hdmi);
233222
if (ret < 0)

drivers/gpu/drm/imx/imx-drm-core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <drm/drm_fb_helper.h>
2121
#include <drm/drm_gem_cma_helper.h>
2222
#include <drm/drm_gem_framebuffer_helper.h>
23+
#include <drm/drm_managed.h>
2324
#include <drm/drm_of.h>
2425
#include <drm/drm_plane_helper.h>
2526
#include <drm/drm_probe_helper.h>
@@ -212,7 +213,9 @@ static int imx_drm_bind(struct device *dev)
212213
drm->mode_config.allow_fb_modifiers = true;
213214
drm->mode_config.normalize_zpos = true;
214215

215-
drm_mode_config_init(drm);
216+
ret = drmm_mode_config_init(drm);
217+
if (ret)
218+
return ret;
216219

217220
ret = drm_vblank_init(drm, MAX_CRTC);
218221
if (ret)
@@ -251,7 +254,6 @@ static int imx_drm_bind(struct device *dev)
251254
drm_kms_helper_poll_fini(drm);
252255
component_unbind_all(drm->dev, drm);
253256
err_kms:
254-
drm_mode_config_cleanup(drm);
255257
drm_dev_put(drm);
256258

257259
return ret;
@@ -267,11 +269,9 @@ static void imx_drm_unbind(struct device *dev)
267269

268270
component_unbind_all(drm->dev, drm);
269271

270-
drm_mode_config_cleanup(drm);
272+
drm_dev_put(drm);
271273

272274
dev_set_drvdata(dev, NULL);
273-
274-
drm_dev_put(drm);
275275
}
276276

277277
static const struct component_master_ops imx_drm_ops = {

drivers/gpu/drm/imx/imx-ldb.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ struct imx_ldb_channel {
6262
struct i2c_adapter *ddc;
6363
int chno;
6464
void *edid;
65-
int edid_len;
6665
struct drm_display_mode mode;
6766
int mode_valid;
6867
u32 bus_format;
@@ -536,15 +535,14 @@ static int imx_ldb_panel_ddc(struct device *dev,
536535
}
537536

538537
if (!channel->ddc) {
538+
int edid_len;
539+
539540
/* if no DDC available, fallback to hardcoded EDID */
540541
dev_dbg(dev, "no ddc available\n");
541542

542-
edidp = of_get_property(child, "edid",
543-
&channel->edid_len);
543+
edidp = of_get_property(child, "edid", &edid_len);
544544
if (edidp) {
545-
channel->edid = kmemdup(edidp,
546-
channel->edid_len,
547-
GFP_KERNEL);
545+
channel->edid = kmemdup(edidp, edid_len, GFP_KERNEL);
548546
} else if (!channel->panel) {
549547
/* fallback to display-timings node */
550548
ret = of_get_drm_display_mode(child,

drivers/gpu/drm/imx/imx-tve.c

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <linux/platform_device.h>
1414
#include <linux/regmap.h>
1515
#include <linux/regulator/consumer.h>
16-
#include <linux/spinlock.h>
1716
#include <linux/videodev2.h>
1817

1918
#include <video/imx-ipu-v3.h>
@@ -104,8 +103,6 @@ struct imx_tve {
104103
struct drm_connector connector;
105104
struct drm_encoder encoder;
106105
struct device *dev;
107-
spinlock_t lock; /* register lock */
108-
bool enabled;
109106
int mode;
110107
int di_hsync_pin;
111108
int di_vsync_pin;
@@ -129,30 +126,10 @@ static inline struct imx_tve *enc_to_tve(struct drm_encoder *e)
129126
return container_of(e, struct imx_tve, encoder);
130127
}
131128

132-
static void tve_lock(void *__tve)
133-
__acquires(&tve->lock)
134-
{
135-
struct imx_tve *tve = __tve;
136-
137-
spin_lock(&tve->lock);
138-
}
139-
140-
static void tve_unlock(void *__tve)
141-
__releases(&tve->lock)
142-
{
143-
struct imx_tve *tve = __tve;
144-
145-
spin_unlock(&tve->lock);
146-
}
147-
148129
static void tve_enable(struct imx_tve *tve)
149130
{
150-
if (!tve->enabled) {
151-
tve->enabled = true;
152-
clk_prepare_enable(tve->clk);
153-
regmap_update_bits(tve->regmap, TVE_COM_CONF_REG,
154-
TVE_EN, TVE_EN);
155-
}
131+
clk_prepare_enable(tve->clk);
132+
regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, TVE_EN);
156133

157134
/* clear interrupt status register */
158135
regmap_write(tve->regmap, TVE_STAT_REG, 0xffffffff);
@@ -169,11 +146,8 @@ static void tve_enable(struct imx_tve *tve)
169146

170147
static void tve_disable(struct imx_tve *tve)
171148
{
172-
if (tve->enabled) {
173-
tve->enabled = false;
174-
regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, 0);
175-
clk_disable_unprepare(tve->clk);
176-
}
149+
regmap_update_bits(tve->regmap, TVE_COM_CONF_REG, TVE_EN, 0);
150+
clk_disable_unprepare(tve->clk);
177151
}
178152

179153
static int tve_setup_tvout(struct imx_tve *tve)
@@ -500,8 +474,7 @@ static struct regmap_config tve_regmap_config = {
500474

501475
.readable_reg = imx_tve_readable_reg,
502476

503-
.lock = tve_lock,
504-
.unlock = tve_unlock,
477+
.fast_io = true,
505478

506479
.max_register = 0xdc,
507480
};
@@ -511,7 +484,7 @@ static const char * const imx_tve_modes[] = {
511484
[TVE_MODE_VGA] = "vga",
512485
};
513486

514-
static const int of_get_tve_mode(struct device_node *np)
487+
static int of_get_tve_mode(struct device_node *np)
515488
{
516489
const char *bm;
517490
int ret, i;
@@ -544,7 +517,6 @@ static int imx_tve_bind(struct device *dev, struct device *master, void *data)
544517
memset(tve, 0, sizeof(*tve));
545518

546519
tve->dev = dev;
547-
spin_lock_init(&tve->lock);
548520

549521
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
550522
if (ddc_node) {

drivers/gpu/drm/imx/parallel-display.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ struct imx_parallel_display {
2828
struct drm_bridge bridge;
2929
struct device *dev;
3030
void *edid;
31-
int edid_len;
3231
u32 bus_format;
3332
u32 bus_flags;
3433
struct drm_display_mode mode;
@@ -41,11 +40,6 @@ static inline struct imx_parallel_display *con_to_imxpd(struct drm_connector *c)
4140
return container_of(c, struct imx_parallel_display, connector);
4241
}
4342

44-
static inline struct imx_parallel_display *enc_to_imxpd(struct drm_encoder *e)
45-
{
46-
return container_of(e, struct imx_parallel_display, encoder);
47-
}
48-
4943
static inline struct imx_parallel_display *bridge_to_imxpd(struct drm_bridge *b)
5044
{
5145
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)
310304
struct device_node *np = dev->of_node;
311305
const u8 *edidp;
312306
struct imx_parallel_display *imxpd;
307+
int edid_len;
313308
int ret;
314309
u32 bus_format = 0;
315310
const char *fmt;
@@ -323,9 +318,9 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
323318
if (ret && ret != -ENODEV)
324319
return ret;
325320

326-
edidp = of_get_property(np, "edid", &imxpd->edid_len);
321+
edidp = of_get_property(np, "edid", &edid_len);
327322
if (edidp)
328-
imxpd->edid = kmemdup(edidp, imxpd->edid_len, GFP_KERNEL);
323+
imxpd->edid = devm_kmemdup(dev, edidp, edid_len, GFP_KERNEL);
329324

330325
ret = of_property_read_string(np, "interface-pix-fmt", &fmt);
331326
if (!ret) {
@@ -349,17 +344,8 @@ static int imx_pd_bind(struct device *dev, struct device *master, void *data)
349344
return 0;
350345
}
351346

352-
static void imx_pd_unbind(struct device *dev, struct device *master,
353-
void *data)
354-
{
355-
struct imx_parallel_display *imxpd = dev_get_drvdata(dev);
356-
357-
kfree(imxpd->edid);
358-
}
359-
360347
static const struct component_ops imx_pd_ops = {
361348
.bind = imx_pd_bind,
362-
.unbind = imx_pd_unbind,
363349
};
364350

365351
static int imx_pd_probe(struct platform_device *pdev)

drivers/gpu/ipu-v3/ipu-common.c

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -133,73 +133,6 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
133133
}
134134
EXPORT_SYMBOL_GPL(ipu_pixelformat_to_colorspace);
135135

136-
bool ipu_pixelformat_is_planar(u32 pixelformat)
137-
{
138-
switch (pixelformat) {
139-
case V4L2_PIX_FMT_YUV420:
140-
case V4L2_PIX_FMT_YVU420:
141-
case V4L2_PIX_FMT_YUV422P:
142-
case V4L2_PIX_FMT_NV12:
143-
case V4L2_PIX_FMT_NV21:
144-
case V4L2_PIX_FMT_NV16:
145-
case V4L2_PIX_FMT_NV61:
146-
return true;
147-
}
148-
149-
return false;
150-
}
151-
EXPORT_SYMBOL_GPL(ipu_pixelformat_is_planar);
152-
153-
enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
154-
{
155-
switch (mbus_code & 0xf000) {
156-
case 0x1000:
157-
return IPUV3_COLORSPACE_RGB;
158-
case 0x2000:
159-
return IPUV3_COLORSPACE_YUV;
160-
default:
161-
return IPUV3_COLORSPACE_UNKNOWN;
162-
}
163-
}
164-
EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
165-
166-
int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
167-
{
168-
switch (pixelformat) {
169-
case V4L2_PIX_FMT_YUV420:
170-
case V4L2_PIX_FMT_YVU420:
171-
case V4L2_PIX_FMT_YUV422P:
172-
case V4L2_PIX_FMT_NV12:
173-
case V4L2_PIX_FMT_NV21:
174-
case V4L2_PIX_FMT_NV16:
175-
case V4L2_PIX_FMT_NV61:
176-
/*
177-
* for the planar YUV formats, the stride passed to
178-
* cpmem must be the stride in bytes of the Y plane.
179-
* And all the planar YUV formats have an 8-bit
180-
* Y component.
181-
*/
182-
return (8 * pixel_stride) >> 3;
183-
case V4L2_PIX_FMT_RGB565:
184-
case V4L2_PIX_FMT_YUYV:
185-
case V4L2_PIX_FMT_UYVY:
186-
return (16 * pixel_stride) >> 3;
187-
case V4L2_PIX_FMT_BGR24:
188-
case V4L2_PIX_FMT_RGB24:
189-
return (24 * pixel_stride) >> 3;
190-
case V4L2_PIX_FMT_BGR32:
191-
case V4L2_PIX_FMT_RGB32:
192-
case V4L2_PIX_FMT_XBGR32:
193-
case V4L2_PIX_FMT_XRGB32:
194-
return (32 * pixel_stride) >> 3;
195-
default:
196-
break;
197-
}
198-
199-
return -EINVAL;
200-
}
201-
EXPORT_SYMBOL_GPL(ipu_stride_to_bytes);
202-
203136
int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
204137
bool hflip, bool vflip)
205138
{

include/video/imx-ipu-v3.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,6 @@ int ipu_smfc_set_watermark(struct ipu_smfc *smfc, u32 set_level, u32 clr_level);
484484

485485
enum ipu_color_space ipu_drm_fourcc_to_colorspace(u32 drm_fourcc);
486486
enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat);
487-
enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code);
488-
int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat);
489-
bool ipu_pixelformat_is_planar(u32 pixelformat);
490487
int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
491488
bool hflip, bool vflip);
492489
int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,

0 commit comments

Comments
 (0)