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-26 23:44:06 +07: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/>.
|
|
|
|
*/
|
|
|
|
|
2017-04-24 11:50:28 +07:00
|
|
|
#include <drm/drm_crtc.h>
|
|
|
|
#include <drm/drm_crtc_helper.h>
|
2018-03-30 21:11:35 +07:00
|
|
|
#include <drm/drm_gem_framebuffer_helper.h>
|
2017-04-24 11:50:28 +07:00
|
|
|
|
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-26 23:44:06 +07:00
|
|
|
#include "msm_drv.h"
|
2013-12-01 04:12:10 +07:00
|
|
|
#include "msm_kms.h"
|
2017-07-11 21:40:13 +07:00
|
|
|
#include "msm_gem.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-26 23:44:06 +07:00
|
|
|
|
|
|
|
struct msm_framebuffer {
|
|
|
|
struct drm_framebuffer base;
|
|
|
|
const struct msm_format *format;
|
|
|
|
};
|
|
|
|
#define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base)
|
|
|
|
|
2017-07-11 21:08:05 +07:00
|
|
|
static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
|
|
|
|
const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
|
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-26 23:44:06 +07:00
|
|
|
|
|
|
|
static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
|
2018-03-30 21:11:35 +07:00
|
|
|
.create_handle = drm_gem_fb_create_handle,
|
|
|
|
.destroy = drm_gem_fb_destroy,
|
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-26 23:44:06 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
|
|
|
|
{
|
2016-12-15 04:30:22 +07:00
|
|
|
int i, n = fb->format->num_planes;
|
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-26 23:44:06 +07:00
|
|
|
|
|
|
|
seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
|
2016-12-15 04:32:55 +07:00
|
|
|
fb->width, fb->height, (char *)&fb->format->format,
|
2016-04-15 12:10:35 +07:00
|
|
|
drm_framebuffer_read_refcount(fb), fb->base.id);
|
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-26 23:44:06 +07:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
seq_printf(m, " %d: offset=%d pitch=%d, obj: ",
|
|
|
|
i, fb->offsets[i], fb->pitches[i]);
|
2018-03-30 21:11:35 +07:00
|
|
|
msm_gem_describe(fb->obj[i], m);
|
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-26 23:44:06 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-08 21:13:37 +07:00
|
|
|
/* prepare/pin all the fb's bo's for scanout. Note that it is not valid
|
|
|
|
* to prepare an fb more multiple different initiator 'id's. But that
|
|
|
|
* should be fine, since only the scanout (mdpN) side of things needs
|
|
|
|
* this, the gpu doesn't care about fb's.
|
|
|
|
*/
|
2017-06-13 22:07:08 +07:00
|
|
|
int msm_framebuffer_prepare(struct drm_framebuffer *fb,
|
|
|
|
struct msm_gem_address_space *aspace)
|
2014-11-08 21:13:37 +07:00
|
|
|
{
|
2016-12-15 04:30:22 +07:00
|
|
|
int ret, i, n = fb->format->num_planes;
|
2016-11-12 00:06:46 +07:00
|
|
|
uint64_t iova;
|
2014-11-08 21:13:37 +07:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2018-03-30 21:11:35 +07:00
|
|
|
ret = msm_gem_get_iova(fb->obj[i], aspace, &iova);
|
2016-11-12 00:06:46 +07:00
|
|
|
DBG("FB[%u]: iova[%d]: %08llx (%d)", fb->base.id, i, iova, ret);
|
2014-11-08 21:13:37 +07:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-06-13 22:07:08 +07:00
|
|
|
void msm_framebuffer_cleanup(struct drm_framebuffer *fb,
|
|
|
|
struct msm_gem_address_space *aspace)
|
2014-11-08 21:13:37 +07:00
|
|
|
{
|
2016-12-15 04:30:22 +07:00
|
|
|
int i, n = fb->format->num_planes;
|
2014-11-08 21:13:37 +07:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
2018-03-30 21:11:35 +07:00
|
|
|
msm_gem_put_iova(fb->obj[i], aspace);
|
2014-11-08 21:13:37 +07:00
|
|
|
}
|
|
|
|
|
2017-06-13 22:07:08 +07:00
|
|
|
uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb,
|
|
|
|
struct msm_gem_address_space *aspace, int plane)
|
2014-11-08 21:13:37 +07:00
|
|
|
{
|
2018-03-30 21:11:35 +07:00
|
|
|
if (!fb->obj[plane])
|
2014-11-20 00:29:33 +07:00
|
|
|
return 0;
|
2018-03-30 21:11:35 +07:00
|
|
|
return msm_gem_iova(fb->obj[plane], aspace) + fb->offsets[plane];
|
2014-11-08 21:13:37 +07:00
|
|
|
}
|
|
|
|
|
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-26 23:44:06 +07:00
|
|
|
struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane)
|
|
|
|
{
|
2018-03-30 21:11:35 +07:00
|
|
|
return drm_gem_fb_get_obj(fb, plane);
|
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-26 23:44:06 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb)
|
|
|
|
{
|
|
|
|
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
|
|
|
|
return msm_fb->format;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct drm_framebuffer *msm_framebuffer_create(struct drm_device *dev,
|
2015-11-12 00:11:29 +07:00
|
|
|
struct drm_file *file, const struct drm_mode_fb_cmd2 *mode_cmd)
|
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-26 23:44:06 +07:00
|
|
|
{
|
|
|
|
struct drm_gem_object *bos[4] = {0};
|
|
|
|
struct drm_framebuffer *fb;
|
|
|
|
int ret, i, n = drm_format_num_planes(mode_cmd->pixel_format);
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2016-05-09 17:04:54 +07:00
|
|
|
bos[i] = drm_gem_object_lookup(file, mode_cmd->handles[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-26 23:44:06 +07:00
|
|
|
if (!bos[i]) {
|
|
|
|
ret = -ENXIO;
|
|
|
|
goto out_unref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fb = msm_framebuffer_init(dev, mode_cmd, bos);
|
|
|
|
if (IS_ERR(fb)) {
|
|
|
|
ret = PTR_ERR(fb);
|
|
|
|
goto out_unref;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
|
|
|
|
out_unref:
|
|
|
|
for (i = 0; i < n; i++)
|
2018-01-26 10:55:54 +07:00
|
|
|
drm_gem_object_put_unlocked(bos[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-26 23:44:06 +07:00
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
|
|
|
|
2017-07-11 21:08:05 +07:00
|
|
|
static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
|
2015-11-12 00:11:29 +07:00
|
|
|
const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos)
|
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-26 23:44:06 +07:00
|
|
|
{
|
|
|
|
struct msm_drm_private *priv = dev->dev_private;
|
|
|
|
struct msm_kms *kms = priv->kms;
|
2015-05-05 20:47:57 +07:00
|
|
|
struct msm_framebuffer *msm_fb = NULL;
|
|
|
|
struct drm_framebuffer *fb;
|
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-26 23:44:06 +07:00
|
|
|
const struct msm_format *format;
|
|
|
|
int ret, i, n;
|
|
|
|
unsigned int hsub, vsub;
|
|
|
|
|
|
|
|
DBG("create framebuffer: dev=%p, mode_cmd=%p (%dx%d@%4.4s)",
|
|
|
|
dev, mode_cmd, mode_cmd->width, mode_cmd->height,
|
|
|
|
(char *)&mode_cmd->pixel_format);
|
|
|
|
|
|
|
|
n = drm_format_num_planes(mode_cmd->pixel_format);
|
|
|
|
hsub = drm_format_horz_chroma_subsampling(mode_cmd->pixel_format);
|
|
|
|
vsub = drm_format_vert_chroma_subsampling(mode_cmd->pixel_format);
|
|
|
|
|
2018-02-14 00:42:44 +07:00
|
|
|
format = kms->funcs->get_format(kms, mode_cmd->pixel_format,
|
|
|
|
mode_cmd->modifier[0]);
|
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-26 23:44:06 +07:00
|
|
|
if (!format) {
|
2018-10-21 00:49:26 +07:00
|
|
|
DRM_DEV_ERROR(dev->dev, "unsupported pixel format: %4.4s\n",
|
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-26 23:44:06 +07:00
|
|
|
(char *)&mode_cmd->pixel_format);
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
msm_fb = kzalloc(sizeof(*msm_fb), GFP_KERNEL);
|
|
|
|
if (!msm_fb) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
fb = &msm_fb->base;
|
|
|
|
|
|
|
|
msm_fb->format = format;
|
|
|
|
|
2018-03-30 21:11:35 +07:00
|
|
|
if (n > ARRAY_SIZE(fb->obj)) {
|
2014-11-08 21:20:28 +07:00
|
|
|
ret = -EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
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-26 23:44:06 +07:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
unsigned int width = mode_cmd->width / (i ? hsub : 1);
|
|
|
|
unsigned int height = mode_cmd->height / (i ? vsub : 1);
|
|
|
|
unsigned int min_size;
|
|
|
|
|
|
|
|
min_size = (height - 1) * mode_cmd->pitches[i]
|
|
|
|
+ width * drm_format_plane_cpp(mode_cmd->pixel_format, i)
|
|
|
|
+ mode_cmd->offsets[i];
|
|
|
|
|
|
|
|
if (bos[i]->size < min_size) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2018-03-30 21:11:35 +07:00
|
|
|
msm_fb->base.obj[i] = bos[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-26 23:44:06 +07:00
|
|
|
}
|
|
|
|
|
drm: Pass 'dev' to drm_helper_mode_fill_fb_struct()
Pass the drm_device to drm_helper_mode_fill_fb_struct() so that we can
populate fb->dev early. Will make it easier to use the fb before we
register it.
@@
identifier fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(
+ struct drm_device *dev,
struct drm_framebuffer *fb,
const struct drm_mode_fb_cmd2 *mode_cmd
);
@@
identifier fb, mode_cmd;
@@
void drm_helper_mode_fill_fb_struct(
+ struct drm_device *dev,
struct drm_framebuffer *fb,
const struct drm_mode_fb_cmd2 *mode_cmd
)
{ ... }
@@
function func;
identifier dev;
expression E1, E2;
@@
func(struct drm_device *dev, ...)
{
...
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
...
}
@@
expression E1, E2;
@@
drm_helper_mode_fill_fb_struct(
+ dev,
E1, E2);
v2: Rerun spatch due to code changes
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1481748539-18283-1-git-send-email-ville.syrjala@linux.intel.com
2016-12-15 03:48:59 +07:00
|
|
|
drm_helper_mode_fill_fb_struct(dev, fb, mode_cmd);
|
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-26 23:44:06 +07:00
|
|
|
|
|
|
|
ret = drm_framebuffer_init(dev, fb, &msm_framebuffer_funcs);
|
|
|
|
if (ret) {
|
2018-10-21 00:49:26 +07:00
|
|
|
DRM_DEV_ERROR(dev->dev, "framebuffer init failed: %d\n", ret);
|
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-26 23:44:06 +07:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG("create: FB ID: %d (%p)", fb->base.id, fb);
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
|
|
|
|
fail:
|
2015-05-05 20:47:57 +07:00
|
|
|
kfree(msm_fb);
|
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-26 23:44:06 +07:00
|
|
|
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
2017-07-11 21:40:13 +07:00
|
|
|
|
|
|
|
struct drm_framebuffer *
|
|
|
|
msm_alloc_stolen_fb(struct drm_device *dev, int w, int h, int p, uint32_t format)
|
|
|
|
{
|
|
|
|
struct drm_mode_fb_cmd2 mode_cmd = {
|
|
|
|
.pixel_format = format,
|
|
|
|
.width = w,
|
|
|
|
.height = h,
|
|
|
|
.pitches = { p },
|
|
|
|
};
|
|
|
|
struct drm_gem_object *bo;
|
|
|
|
struct drm_framebuffer *fb;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
/* allocate backing bo */
|
|
|
|
size = mode_cmd.pitches[0] * mode_cmd.height;
|
|
|
|
DBG("allocating %d bytes for fb %d", size, dev->primary->index);
|
|
|
|
bo = msm_gem_new(dev, size, MSM_BO_SCANOUT | MSM_BO_WC | MSM_BO_STOLEN);
|
|
|
|
if (IS_ERR(bo)) {
|
|
|
|
dev_warn(dev->dev, "could not allocate stolen bo\n");
|
|
|
|
/* try regular bo: */
|
|
|
|
bo = msm_gem_new(dev, size, MSM_BO_SCANOUT | MSM_BO_WC);
|
|
|
|
}
|
|
|
|
if (IS_ERR(bo)) {
|
2018-10-21 00:49:26 +07:00
|
|
|
DRM_DEV_ERROR(dev->dev, "failed to allocate buffer object\n");
|
2017-07-11 21:40:13 +07:00
|
|
|
return ERR_CAST(bo);
|
|
|
|
}
|
|
|
|
|
|
|
|
fb = msm_framebuffer_init(dev, &mode_cmd, &bo);
|
|
|
|
if (IS_ERR(fb)) {
|
2018-10-21 00:49:26 +07:00
|
|
|
DRM_DEV_ERROR(dev->dev, "failed to allocate fb\n");
|
2017-07-11 21:40:13 +07:00
|
|
|
/* note: if fb creation failed, we can't rely on fb destroy
|
|
|
|
* to unref the bo:
|
|
|
|
*/
|
2018-01-26 10:55:54 +07:00
|
|
|
drm_gem_object_put_unlocked(bo);
|
2017-07-11 21:40:13 +07:00
|
|
|
return ERR_CAST(fb);
|
|
|
|
}
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
}
|