Commit 4abfe15e authored by Dave Airlie's avatar Dave Airlie

Merge tag 'imx-drm-next-2018-08-03' of git://git.pengutronix.de/git/pza/linux into drm-next

drm/imx: use suspend/resume helpers, add ipu-v3 V4L2 XRGB32/XBGR32 support

- Convert imx_drm_suspend/resume to use the
  drm_mode_config_helper_suspend/ resume functions.
- Add support for V4L2_PIX_FMT_XRGB32/XBGR32, corresponding to
  DRM_FORMAT_XRGB8888/BGRX8888, respectively.
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
From: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://patchwork.freedesktop.org/patch/msgid/1533552701.4204.15.camel@pengutronix.de
parents 824da016 5c41bb60
...@@ -35,11 +35,6 @@ ...@@ -35,11 +35,6 @@
#define MAX_CRTC 4 #define MAX_CRTC 4
struct imx_drm_device {
struct drm_device *drm;
struct drm_atomic_state *state;
};
#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
static int legacyfb_depth = 16; static int legacyfb_depth = 16;
module_param(legacyfb_depth, int, 0444); module_param(legacyfb_depth, int, 0444);
...@@ -218,22 +213,12 @@ static int compare_of(struct device *dev, void *data) ...@@ -218,22 +213,12 @@ static int compare_of(struct device *dev, void *data)
static int imx_drm_bind(struct device *dev) static int imx_drm_bind(struct device *dev)
{ {
struct drm_device *drm; struct drm_device *drm;
struct imx_drm_device *imxdrm;
int ret; int ret;
drm = drm_dev_alloc(&imx_drm_driver, dev); drm = drm_dev_alloc(&imx_drm_driver, dev);
if (IS_ERR(drm)) if (IS_ERR(drm))
return PTR_ERR(drm); return PTR_ERR(drm);
imxdrm = devm_kzalloc(dev, sizeof(*imxdrm), GFP_KERNEL);
if (!imxdrm) {
ret = -ENOMEM;
goto err_put;
}
imxdrm->drm = drm;
drm->dev_private = imxdrm;
/* /*
* enable drm irq mode. * enable drm irq mode.
* - with irq_enabled = true, we can use the vblank feature. * - with irq_enabled = true, we can use the vblank feature.
...@@ -305,7 +290,6 @@ static int imx_drm_bind(struct device *dev) ...@@ -305,7 +290,6 @@ static int imx_drm_bind(struct device *dev)
component_unbind_all(drm->dev, drm); component_unbind_all(drm->dev, drm);
err_kms: err_kms:
drm_mode_config_cleanup(drm); drm_mode_config_cleanup(drm);
err_put:
drm_dev_put(drm); drm_dev_put(drm);
return ret; return ret;
...@@ -354,37 +338,15 @@ static int imx_drm_platform_remove(struct platform_device *pdev) ...@@ -354,37 +338,15 @@ static int imx_drm_platform_remove(struct platform_device *pdev)
static int imx_drm_suspend(struct device *dev) static int imx_drm_suspend(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct imx_drm_device *imxdrm;
/* The drm_dev is NULL before .load hook is called */
if (drm_dev == NULL)
return 0;
drm_kms_helper_poll_disable(drm_dev);
imxdrm = drm_dev->dev_private; return drm_mode_config_helper_suspend(drm_dev);
imxdrm->state = drm_atomic_helper_suspend(drm_dev);
if (IS_ERR(imxdrm->state)) {
drm_kms_helper_poll_enable(drm_dev);
return PTR_ERR(imxdrm->state);
}
return 0;
} }
static int imx_drm_resume(struct device *dev) static int imx_drm_resume(struct device *dev)
{ {
struct drm_device *drm_dev = dev_get_drvdata(dev); struct drm_device *drm_dev = dev_get_drvdata(dev);
struct imx_drm_device *imx_drm;
if (drm_dev == NULL) return drm_mode_config_helper_resume(drm_dev);
return 0;
imx_drm = drm_dev->dev_private;
drm_atomic_helper_resume(drm_dev, imx_drm->state);
drm_kms_helper_poll_enable(drm_dev);
return 0;
} }
#endif #endif
......
...@@ -122,6 +122,8 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat) ...@@ -122,6 +122,8 @@ enum ipu_color_space ipu_pixelformat_to_colorspace(u32 pixelformat)
case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_NV16:
case V4L2_PIX_FMT_NV61: case V4L2_PIX_FMT_NV61:
return IPUV3_COLORSPACE_YUV; return IPUV3_COLORSPACE_YUV;
case V4L2_PIX_FMT_XRGB32:
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_RGB32:
case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_RGB24:
...@@ -190,6 +192,8 @@ int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat) ...@@ -190,6 +192,8 @@ int ipu_stride_to_bytes(u32 pixel_stride, u32 pixelformat)
return (24 * pixel_stride) >> 3; return (24 * pixel_stride) >> 3;
case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_RGB32:
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_XRGB32:
return (32 * pixel_stride) >> 3; return (32 * pixel_stride) >> 3;
default: default:
break; break;
......
...@@ -188,6 +188,12 @@ static int v4l2_pix_fmt_to_drm_fourcc(u32 pixelformat) ...@@ -188,6 +188,12 @@ static int v4l2_pix_fmt_to_drm_fourcc(u32 pixelformat)
case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_RGB32:
/* R G B A <=> [32:0] A:B:G:R */ /* R G B A <=> [32:0] A:B:G:R */
return DRM_FORMAT_XBGR8888; return DRM_FORMAT_XBGR8888;
case V4L2_PIX_FMT_XBGR32:
/* B G R X <=> [32:0] X:R:G:B */
return DRM_FORMAT_XRGB8888;
case V4L2_PIX_FMT_XRGB32:
/* X R G B <=> [32:0] B:G:R:X */
return DRM_FORMAT_BGRX8888;
case V4L2_PIX_FMT_UYVY: case V4L2_PIX_FMT_UYVY:
return DRM_FORMAT_UYVY; return DRM_FORMAT_UYVY;
case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YUYV:
...@@ -787,6 +793,8 @@ int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image) ...@@ -787,6 +793,8 @@ int ipu_cpmem_set_image(struct ipuv3_channel *ch, struct ipu_image *image)
break; break;
case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_RGB32:
case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_XRGB32:
case V4L2_PIX_FMT_XBGR32:
offset = image->rect.left * 4 + offset = image->rect.left * 4 +
image->rect.top * pix->bytesperline; image->rect.top * pix->bytesperline;
break; break;
......
...@@ -226,6 +226,12 @@ static const struct ipu_image_pixfmt image_convert_formats[] = { ...@@ -226,6 +226,12 @@ static const struct ipu_image_pixfmt image_convert_formats[] = {
}, { }, {
.fourcc = V4L2_PIX_FMT_BGR32, .fourcc = V4L2_PIX_FMT_BGR32,
.bpp = 32, .bpp = 32,
}, {
.fourcc = V4L2_PIX_FMT_XRGB32,
.bpp = 32,
}, {
.fourcc = V4L2_PIX_FMT_XBGR32,
.bpp = 32,
}, { }, {
.fourcc = V4L2_PIX_FMT_YUYV, .fourcc = V4L2_PIX_FMT_YUYV,
.bpp = 16, .bpp = 16,
......
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