Merge tag 'arcpgu-updates-2019.12.16' of github.com:abrodkin/linux into drm-next

Clean-up and fixes for FourCC handling in ARC PGU.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
From: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Link: https://patchwork.freedesktop.org/patch/msgid/CY4PR1201MB01204228B5788F0A6619FE45A1510@CY4PR1201MB0120.namprd12.prod.outlook.com
This commit is contained in:
Daniel Vetter 2019-12-17 14:27:04 +01:00
commit d2e532286d
2 changed files with 19 additions and 19 deletions

View File

@ -20,9 +20,10 @@
#define ENCODE_PGU_XY(x, y) ((((x) - 1) << 16) | ((y) - 1)) #define ENCODE_PGU_XY(x, y) ((((x) - 1) << 16) | ((y) - 1))
static struct simplefb_format supported_formats[] = { static const u32 arc_pgu_supported_formats[] = {
{ "r5g6b5", 16, {11, 5}, {5, 6}, {0, 5}, {0, 0}, DRM_FORMAT_RGB565 }, DRM_FORMAT_RGB565,
{ "r8g8b8", 24, {16, 8}, {8, 8}, {0, 8}, {0, 0}, DRM_FORMAT_RGB888 }, DRM_FORMAT_XRGB8888,
DRM_FORMAT_ARGB8888,
}; };
static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc) static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
@ -30,22 +31,24 @@ static void arc_pgu_set_pxl_fmt(struct drm_crtc *crtc)
struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc); struct arcpgu_drm_private *arcpgu = crtc_to_arcpgu_priv(crtc);
const struct drm_framebuffer *fb = crtc->primary->state->fb; const struct drm_framebuffer *fb = crtc->primary->state->fb;
uint32_t pixel_format = fb->format->format; uint32_t pixel_format = fb->format->format;
struct simplefb_format *format = NULL; u32 format = DRM_FORMAT_INVALID;
int i; int i;
u32 reg_ctrl;
for (i = 0; i < ARRAY_SIZE(supported_formats); i++) { for (i = 0; i < ARRAY_SIZE(arc_pgu_supported_formats); i++) {
if (supported_formats[i].fourcc == pixel_format) if (arc_pgu_supported_formats[i] == pixel_format)
format = &supported_formats[i]; format = arc_pgu_supported_formats[i];
} }
if (WARN_ON(!format)) if (WARN_ON(format == DRM_FORMAT_INVALID))
return; return;
if (format->fourcc == DRM_FORMAT_RGB888) reg_ctrl = arc_pgu_read(arcpgu, ARCPGU_REG_CTRL);
arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, if (format == DRM_FORMAT_RGB565)
arc_pgu_read(arcpgu, ARCPGU_REG_CTRL) | reg_ctrl &= ~ARCPGU_MODE_XRGB8888;
ARCPGU_MODE_RGB888_MASK); else
reg_ctrl |= ARCPGU_MODE_XRGB8888;
arc_pgu_write(arcpgu, ARCPGU_REG_CTRL, reg_ctrl);
} }
static const struct drm_crtc_funcs arc_pgu_crtc_funcs = { static const struct drm_crtc_funcs arc_pgu_crtc_funcs = {
@ -193,18 +196,15 @@ static struct drm_plane *arc_pgu_plane_init(struct drm_device *drm)
{ {
struct arcpgu_drm_private *arcpgu = drm->dev_private; struct arcpgu_drm_private *arcpgu = drm->dev_private;
struct drm_plane *plane = NULL; struct drm_plane *plane = NULL;
u32 formats[ARRAY_SIZE(supported_formats)], i;
int ret; int ret;
plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL); plane = devm_kzalloc(drm->dev, sizeof(*plane), GFP_KERNEL);
if (!plane) if (!plane)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
for (i = 0; i < ARRAY_SIZE(supported_formats); i++)
formats[i] = supported_formats[i].fourcc;
ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs, ret = drm_universal_plane_init(drm, plane, 0xff, &arc_pgu_plane_funcs,
formats, ARRAY_SIZE(formats), arc_pgu_supported_formats,
ARRAY_SIZE(arc_pgu_supported_formats),
NULL, NULL,
DRM_PLANE_TYPE_PRIMARY, NULL); DRM_PLANE_TYPE_PRIMARY, NULL);
if (ret) if (ret)

View File

@ -25,7 +25,7 @@
#define ARCPGU_CTRL_VS_POL_OFST 0x3 #define ARCPGU_CTRL_VS_POL_OFST 0x3
#define ARCPGU_CTRL_HS_POL_MASK 0x1 #define ARCPGU_CTRL_HS_POL_MASK 0x1
#define ARCPGU_CTRL_HS_POL_OFST 0x4 #define ARCPGU_CTRL_HS_POL_OFST 0x4
#define ARCPGU_MODE_RGB888_MASK 0x04 #define ARCPGU_MODE_XRGB8888 BIT(2)
#define ARCPGU_STAT_BUSY_MASK 0x02 #define ARCPGU_STAT_BUSY_MASK 0x02
#endif #endif