drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
/*
|
2014-12-08 23:48:57 +08:00
|
|
|
* Copyright (c) 2014 The Linux Foundation. All rights reserved.
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
* Copyright (C) 2013 Red Hat
|
|
|
|
* Author: Rob Clark <robdclark@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "msm_drv.h"
|
2013-12-01 03:58:23 +08:00
|
|
|
#include "mdp_kms.h"
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
|
2014-12-08 23:48:57 +08:00
|
|
|
static struct csc_cfg csc_convert[CSC_MAX] = {
|
|
|
|
[CSC_RGB2RGB] = {
|
|
|
|
.type = CSC_RGB2RGB,
|
|
|
|
.matrix = {
|
|
|
|
0x0200, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0200, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0200
|
|
|
|
},
|
|
|
|
.pre_bias = { 0x0, 0x0, 0x0 },
|
|
|
|
.post_bias = { 0x0, 0x0, 0x0 },
|
|
|
|
.pre_clamp = { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff },
|
|
|
|
.post_clamp = { 0x0, 0xff, 0x0, 0xff, 0x0, 0xff },
|
|
|
|
},
|
|
|
|
[CSC_YUV2RGB] = {
|
|
|
|
.type = CSC_YUV2RGB,
|
|
|
|
.matrix = {
|
|
|
|
0x0254, 0x0000, 0x0331,
|
|
|
|
0x0254, 0xff37, 0xfe60,
|
|
|
|
0x0254, 0x0409, 0x0000
|
|
|
|
},
|
|
|
|
.pre_bias = { 0xfff0, 0xff80, 0xff80 },
|
|
|
|
.post_bias = { 0x00, 0x00, 0x00 },
|
|
|
|
.pre_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff },
|
|
|
|
.post_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff },
|
|
|
|
},
|
|
|
|
[CSC_RGB2YUV] = {
|
|
|
|
.type = CSC_RGB2YUV,
|
|
|
|
.matrix = {
|
|
|
|
0x0083, 0x0102, 0x0032,
|
|
|
|
0x1fb5, 0x1f6c, 0x00e1,
|
|
|
|
0x00e1, 0x1f45, 0x1fdc
|
|
|
|
},
|
|
|
|
.pre_bias = { 0x00, 0x00, 0x00 },
|
|
|
|
.post_bias = { 0x10, 0x80, 0x80 },
|
|
|
|
.pre_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff },
|
|
|
|
.post_clamp = { 0x10, 0xeb, 0x10, 0xf0, 0x10, 0xf0 },
|
|
|
|
},
|
|
|
|
[CSC_YUV2YUV] = {
|
|
|
|
.type = CSC_YUV2YUV,
|
|
|
|
.matrix = {
|
|
|
|
0x0200, 0x0000, 0x0000,
|
|
|
|
0x0000, 0x0200, 0x0000,
|
|
|
|
0x0000, 0x0000, 0x0200
|
|
|
|
},
|
|
|
|
.pre_bias = { 0x00, 0x00, 0x00 },
|
|
|
|
.post_bias = { 0x00, 0x00, 0x00 },
|
|
|
|
.pre_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff },
|
|
|
|
.post_clamp = { 0x00, 0xff, 0x00, 0xff, 0x00, 0xff },
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
#define FMT(name, a, r, g, b, e0, e1, e2, e3, alpha, tight, c, cnt, fp, cs) { \
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
.base = { .pixel_format = DRM_FORMAT_ ## name }, \
|
|
|
|
.bpc_a = BPC ## a ## A, \
|
|
|
|
.bpc_r = BPC ## r, \
|
|
|
|
.bpc_g = BPC ## g, \
|
|
|
|
.bpc_b = BPC ## b, \
|
|
|
|
.unpack = { e0, e1, e2, e3 }, \
|
|
|
|
.alpha_enable = alpha, \
|
|
|
|
.unpack_tight = tight, \
|
|
|
|
.cpp = c, \
|
|
|
|
.unpack_count = cnt, \
|
2014-12-08 23:48:57 +08:00
|
|
|
.fetch_type = fp, \
|
|
|
|
.chroma_sample = cs \
|
|
|
|
}
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
|
|
|
|
#define BPC0A 0
|
|
|
|
|
2014-12-08 23:48:57 +08:00
|
|
|
/*
|
|
|
|
* Note: Keep RGB formats 1st, followed by YUV formats to avoid breaking
|
|
|
|
* mdp_get_rgb_formats()'s implementation.
|
|
|
|
*/
|
2013-12-01 03:58:23 +08:00
|
|
|
static const struct mdp_format formats[] = {
|
2014-12-08 23:48:57 +08:00
|
|
|
/* name a r g b e0 e1 e2 e3 alpha tight cpp cnt ... */
|
|
|
|
FMT(ARGB8888, 8, 8, 8, 8, 1, 0, 2, 3, true, true, 4, 4,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2015-06-04 05:27:21 +08:00
|
|
|
FMT(ABGR8888, 8, 8, 8, 8, 2, 0, 1, 3, true, true, 4, 4,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2015-06-04 05:27:21 +08:00
|
|
|
FMT(RGBA8888, 8, 8, 8, 8, 3, 1, 0, 2, true, true, 4, 4,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2015-06-04 05:27:21 +08:00
|
|
|
FMT(BGRA8888, 8, 8, 8, 8, 3, 2, 0, 1, true, true, 4, 4,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2014-12-08 23:48:57 +08:00
|
|
|
FMT(XRGB8888, 8, 8, 8, 8, 1, 0, 2, 3, false, true, 4, 4,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2014-12-08 23:48:57 +08:00
|
|
|
FMT(RGB888, 0, 8, 8, 8, 1, 0, 2, 0, false, true, 3, 3,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2014-12-08 23:48:57 +08:00
|
|
|
FMT(BGR888, 0, 8, 8, 8, 2, 0, 1, 0, false, true, 3, 3,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2014-12-08 23:48:57 +08:00
|
|
|
FMT(RGB565, 0, 5, 6, 5, 1, 0, 2, 0, false, true, 2, 3,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2014-12-08 23:48:57 +08:00
|
|
|
FMT(BGR565, 0, 5, 6, 5, 2, 0, 1, 0, false, true, 2, 3,
|
2015-07-28 07:37:12 +08:00
|
|
|
MDP_PLANE_INTERLEAVED, CHROMA_FULL),
|
2014-12-08 23:48:57 +08:00
|
|
|
|
|
|
|
/* --- RGB formats above / YUV formats below this line --- */
|
|
|
|
|
|
|
|
FMT(NV12, 0, 8, 8, 8, 1, 2, 0, 0, false, true, 2, 2,
|
|
|
|
MDP_PLANE_PSEUDO_PLANAR, CHROMA_420),
|
|
|
|
FMT(NV21, 0, 8, 8, 8, 2, 1, 0, 0, false, true, 2, 2,
|
|
|
|
MDP_PLANE_PSEUDO_PLANAR, CHROMA_420),
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
};
|
|
|
|
|
2014-12-08 23:48:57 +08:00
|
|
|
/*
|
|
|
|
* Note:
|
|
|
|
* @rgb_only must be set to true, when requesting
|
|
|
|
* supported formats for RGB pipes.
|
|
|
|
*/
|
|
|
|
uint32_t mdp_get_formats(uint32_t *pixel_formats, uint32_t max_formats,
|
|
|
|
bool rgb_only)
|
2013-10-09 00:57:48 +08:00
|
|
|
{
|
|
|
|
uint32_t i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(formats); i++) {
|
2013-12-01 03:58:23 +08:00
|
|
|
const struct mdp_format *f = &formats[i];
|
2013-10-09 00:57:48 +08:00
|
|
|
|
|
|
|
if (i == max_formats)
|
|
|
|
break;
|
|
|
|
|
2014-12-08 23:48:57 +08:00
|
|
|
if (rgb_only && MDP_FORMAT_IS_YUV(f))
|
|
|
|
break;
|
|
|
|
|
2013-10-09 00:57:48 +08:00
|
|
|
pixel_formats[i] = f->base.pixel_format;
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2013-12-01 03:58:23 +08:00
|
|
|
const struct msm_format *mdp_get_format(struct msm_kms *kms, uint32_t format)
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(formats); i++) {
|
2013-12-01 03:58:23 +08:00
|
|
|
const struct mdp_format *f = &formats[i];
|
drm/msm: basic KMS driver for snapdragon
The snapdragon chips have multiple different display controllers,
depending on which chip variant/version. (As far as I can tell, current
devices have either MDP3 or MDP4, and upcoming devices have MDSS.) And
then external to the display controller are HDMI, DSI, etc. blocks which
may be shared across devices which have different display controller
blocks.
To more easily add support for different display controller blocks, the
display controller specific bits are split out into a "kms" module,
which provides the kms plane/crtc/encoder objects.
The external HDMI, DSI, etc. blocks are part encoder, and part connector
currently. But I think I will pull in the drm_bridge patches from
chromeos tree, and split them into a bridge+connector, with the
registers that need to be set in modeset handled by the bridge. This
would remove the 'msm_connector' base class. But some things need to be
double checked to make sure I could get the correct ON/OFF sequencing..
This patch adds support for mdp4 crtc (including hw cursor), dtv encoder
(part of MDP4 block), and hdmi.
Signed-off-by: Rob Clark <robdclark@gmail.com>
2013-06-27 00:44:06 +08:00
|
|
|
if (f->base.pixel_format == format)
|
|
|
|
return &f->base;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2014-12-08 23:48:57 +08:00
|
|
|
|
|
|
|
struct csc_cfg *mdp_get_default_csc_cfg(enum csc_type type)
|
|
|
|
{
|
|
|
|
if (unlikely(WARN_ON(type >= CSC_MAX)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return &csc_convert[type];
|
|
|
|
}
|