2019-06-03 07:44:50 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
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 12:44:06 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Red Hat
|
|
|
|
* Author: Rob Clark <robdclark@gmail.com>
|
|
|
|
*/
|
|
|
|
|
2017-04-24 13:50:28 +09:00
|
|
|
#include <drm/drm_crtc.h>
|
2019-05-31 05:46:14 -04:00
|
|
|
#include <drm/drm_damage_helper.h>
|
2019-08-04 08:55:51 +02:00
|
|
|
#include <drm/drm_file.h>
|
|
|
|
#include <drm/drm_fourcc.h>
|
2022-06-14 12:54:49 +03:00
|
|
|
#include <drm/drm_framebuffer.h>
|
2018-03-30 15:11:35 +01:00
|
|
|
#include <drm/drm_gem_framebuffer_helper.h>
|
2019-01-17 22:03:34 +01:00
|
|
|
#include <drm/drm_probe_helper.h>
|
2017-04-24 13:50:28 +09: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 12:44:06 -04:00
|
|
|
#include "msm_drv.h"
|
2013-11-30 16:12:10 -05:00
|
|
|
#include "msm_kms.h"
|
2017-07-11 10:40:13 -04: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 12:44:06 -04:00
|
|
|
|
|
|
|
struct msm_framebuffer {
|
|
|
|
struct drm_framebuffer base;
|
|
|
|
const struct msm_format *format;
|
2022-02-23 11:11:08 -08:00
|
|
|
|
|
|
|
/* Count of # of attached planes which need dirtyfb: */
|
|
|
|
refcount_t dirtyfb;
|
2022-04-11 14:58:35 -07:00
|
|
|
|
|
|
|
/* Framebuffer per-plane address, if pinned, else zero: */
|
|
|
|
uint64_t iova[DRM_FORMAT_MAX_PLANES];
|
|
|
|
atomic_t prepare_count;
|
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 12:44:06 -04:00
|
|
|
};
|
|
|
|
#define to_msm_framebuffer(x) container_of(x, struct msm_framebuffer, base)
|
|
|
|
|
2017-07-11 10:08:05 -04:00
|
|
|
static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
|
2025-07-01 12:07:18 +03:00
|
|
|
const struct drm_format_info *info,
|
2017-07-11 10:08:05 -04: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 12:44:06 -04:00
|
|
|
|
2022-02-23 11:11:08 -08:00
|
|
|
static int msm_framebuffer_dirtyfb(struct drm_framebuffer *fb,
|
|
|
|
struct drm_file *file_priv, unsigned int flags,
|
|
|
|
unsigned int color, struct drm_clip_rect *clips,
|
|
|
|
unsigned int num_clips)
|
|
|
|
{
|
|
|
|
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
|
|
|
|
|
|
|
|
/* If this fb is not used on any display requiring pixel data to be
|
|
|
|
* flushed, then skip dirtyfb
|
|
|
|
*/
|
2022-03-04 12:21:45 -08:00
|
|
|
if (refcount_read(&msm_fb->dirtyfb) == 1)
|
2022-02-23 11:11:08 -08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return drm_atomic_helper_dirtyfb(fb, file_priv, flags, color,
|
|
|
|
clips, num_clips);
|
|
|
|
}
|
|
|
|
|
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 12:44:06 -04:00
|
|
|
static const struct drm_framebuffer_funcs msm_framebuffer_funcs = {
|
2018-03-30 15:11:35 +01:00
|
|
|
.create_handle = drm_gem_fb_create_handle,
|
|
|
|
.destroy = drm_gem_fb_destroy,
|
2022-02-23 11:11:08 -08:00
|
|
|
.dirty = msm_framebuffer_dirtyfb,
|
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 12:44:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_FS
|
|
|
|
void msm_framebuffer_describe(struct drm_framebuffer *fb, struct seq_file *m)
|
|
|
|
{
|
2021-03-31 18:27:21 -07:00
|
|
|
struct msm_gem_stats stats = {};
|
2016-12-14 23:30:22 +02: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 12:44:06 -04:00
|
|
|
|
|
|
|
seq_printf(m, "fb: %dx%d@%4.4s (%2d, ID:%d)\n",
|
2016-12-14 23:32:55 +02:00
|
|
|
fb->width, fb->height, (char *)&fb->format->format,
|
2016-04-15 15:10:35 +10: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 12:44:06 -04:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
seq_printf(m, " %d: offset=%d pitch=%d, obj: ",
|
|
|
|
i, fb->offsets[i], fb->pitches[i]);
|
2021-03-31 18:27:21 -07:00
|
|
|
msm_gem_describe(fb->obj[i], m, &stats);
|
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 12:44:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2022-02-23 11:11:08 -08:00
|
|
|
/* prepare/pin all the fb's bo's for scanout.
|
2014-11-08 09:13:37 -05:00
|
|
|
*/
|
2025-06-29 13:12:54 -07:00
|
|
|
int msm_framebuffer_prepare(struct drm_framebuffer *fb, bool needs_dirtyfb)
|
2014-11-08 09:13:37 -05:00
|
|
|
{
|
2025-06-29 13:12:54 -07:00
|
|
|
struct msm_drm_private *priv = fb->dev->dev_private;
|
2025-06-29 13:12:58 -07:00
|
|
|
struct drm_gpuvm *vm = priv->kms->vm;
|
2022-02-23 11:11:08 -08:00
|
|
|
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
|
2016-12-14 23:30:22 +02:00
|
|
|
int ret, i, n = fb->format->num_planes;
|
2014-11-08 09:13:37 -05:00
|
|
|
|
2022-02-23 11:11:08 -08:00
|
|
|
if (needs_dirtyfb)
|
|
|
|
refcount_inc(&msm_fb->dirtyfb);
|
|
|
|
|
2025-06-29 13:12:55 -07:00
|
|
|
if (atomic_inc_return(&msm_fb->prepare_count) > 1)
|
|
|
|
return 0;
|
2022-04-11 14:58:35 -07:00
|
|
|
|
2014-11-08 09:13:37 -05:00
|
|
|
for (i = 0; i < n; i++) {
|
2025-06-29 13:13:24 -07:00
|
|
|
msm_gem_vma_get(fb->obj[i]);
|
2025-06-29 13:12:49 -07:00
|
|
|
ret = msm_gem_get_and_pin_iova(fb->obj[i], vm, &msm_fb->iova[i]);
|
2024-03-25 14:08:09 -07:00
|
|
|
drm_dbg_state(fb->dev, "FB[%u]: iova[%d]: %08llx (%d)\n",
|
2022-04-11 14:58:35 -07:00
|
|
|
fb->base.id, i, msm_fb->iova[i], ret);
|
2014-11-08 09:13:37 -05:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2025-06-29 13:12:54 -07:00
|
|
|
void msm_framebuffer_cleanup(struct drm_framebuffer *fb, bool needed_dirtyfb)
|
2014-11-08 09:13:37 -05:00
|
|
|
{
|
2025-06-29 13:12:54 -07:00
|
|
|
struct msm_drm_private *priv = fb->dev->dev_private;
|
2025-06-29 13:12:58 -07:00
|
|
|
struct drm_gpuvm *vm = priv->kms->vm;
|
2022-02-23 11:11:08 -08:00
|
|
|
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
|
2016-12-14 23:30:22 +02:00
|
|
|
int i, n = fb->format->num_planes;
|
2014-11-08 09:13:37 -05:00
|
|
|
|
2022-02-23 11:11:08 -08:00
|
|
|
if (needed_dirtyfb)
|
|
|
|
refcount_dec(&msm_fb->dirtyfb);
|
|
|
|
|
2025-06-29 13:12:55 -07:00
|
|
|
if (atomic_dec_return(&msm_fb->prepare_count))
|
|
|
|
return;
|
|
|
|
|
|
|
|
memset(msm_fb->iova, 0, sizeof(msm_fb->iova));
|
|
|
|
|
2025-06-29 13:13:24 -07:00
|
|
|
for (i = 0; i < n; i++) {
|
2025-06-29 13:12:49 -07:00
|
|
|
msm_gem_unpin_iova(fb->obj[i], vm);
|
2025-06-29 13:13:24 -07:00
|
|
|
msm_gem_vma_put(fb->obj[i]);
|
|
|
|
}
|
2014-11-08 09:13:37 -05:00
|
|
|
}
|
|
|
|
|
2025-06-29 13:12:54 -07:00
|
|
|
uint32_t msm_framebuffer_iova(struct drm_framebuffer *fb, int plane)
|
2014-11-08 09:13:37 -05:00
|
|
|
{
|
2022-04-11 14:58:35 -07:00
|
|
|
struct msm_framebuffer *msm_fb = to_msm_framebuffer(fb);
|
2022-05-10 09:52:16 -07:00
|
|
|
return msm_fb->iova[plane] + fb->offsets[plane];
|
2014-11-08 09:13:37 -05: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 12:44:06 -04:00
|
|
|
struct drm_gem_object *msm_framebuffer_bo(struct drm_framebuffer *fb, int plane)
|
|
|
|
{
|
2018-03-30 15:11:35 +01: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 12:44:06 -04: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,
|
drm: Pass the format info to .fb_create()
Pass along the format information from the top to .fb_create()
so that we can avoid redundant (and somewhat expensive) lookups
in the drivers.
Done with cocci (with some manual fixups):
@@
identifier func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
...
(
- const struct drm_format_info *info = drm_get_format_info(...);
|
- const struct drm_format_info *info;
...
- info = drm_get_format_info(...);
)
<...
- if (!info)
- return ...;
...>
}
@@
identifier func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd)
{
...
}
@find@
identifier fb_create_func =~ ".*create.*";
identifier dev, file, mode_cmd;
@@
struct drm_framebuffer *fb_create_func(
struct drm_device *dev,
struct drm_file *file,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd);
@@
identifier find.fb_create_func;
expression dev, file, mode_cmd;
@@
fb_create_func(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file, mode_cmd;
@@
drm_gem_fb_create(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file, mode_cmd;
@@
drm_gem_fb_create_with_dirty(dev, file
+ ,info
,mode_cmd)
@@
expression dev, file_priv, mode_cmd;
identifier info, fb;
@@
info = drm_get_format_info(...);
...
fb = dev->mode_config.funcs->fb_create(dev, file_priv
+ ,info
,mode_cmd);
@@
identifier dev, file_priv, mode_cmd;
@@
struct drm_mode_config_funcs {
...
struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
struct drm_file *file_priv,
+ const struct drm_format_info *info,
const struct drm_mode_fb_cmd2 *mode_cmd);
...
};
v2: Fix kernel docs (Laurent)
Fix commit msg (Geert)
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Inki Dae <inki.dae@samsung.com>
Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Abhinav Kumar <quic_abhinavk@quicinc.com>
Cc: Dmitry Baryshkov <lumag@kernel.org>
Cc: Sean Paul <sean@poorly.run>
Cc: Marijn Suijten <marijn.suijten@somainline.org>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Agner <stefan@agner.ch>
Cc: Lyude Paul <lyude@redhat.com>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Cc: Biju Das <biju.das.jz@bp.renesas.com>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Andy Yan <andy.yan@rock-chips.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Mikko Perttunen <mperttunen@nvidia.com>
Cc: Dave Stevenson <dave.stevenson@raspberrypi.com>
Cc: "Maíra Canal" <mcanal@igalia.com>
Cc: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: Gurchetan Singh <gurchetansingh@chromium.org>
Cc: Chia-I Wu <olvaffe@gmail.com>
Cc: Zack Rusin <zack.rusin@broadcom.com>
Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com>
Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: linux-arm-msm@vger.kernel.org
Cc: freedreno@lists.freedesktop.org
Cc: nouveau@lists.freedesktop.org
Cc: virtualization@lists.linux.dev
Cc: spice-devel@lists.freedesktop.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-tegra@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Acked-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-5-ville.syrjala@linux.intel.com
2025-07-01 12:07:07 +03:00
|
|
|
struct drm_file *file, const struct drm_format_info *info,
|
|
|
|
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 12:44:06 -04:00
|
|
|
{
|
|
|
|
struct drm_gem_object *bos[4] = {0};
|
|
|
|
struct drm_framebuffer *fb;
|
2019-05-16 12:31:47 +02:00
|
|
|
int ret, i, n = info->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 12:44:06 -04:00
|
|
|
|
|
|
|
for (i = 0; i < n; i++) {
|
2016-05-09 11:04:54 +01: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 12:44:06 -04:00
|
|
|
if (!bos[i]) {
|
|
|
|
ret = -ENXIO;
|
|
|
|
goto out_unref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-07-01 12:07:18 +03:00
|
|
|
fb = msm_framebuffer_init(dev, info, mode_cmd, 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 12:44:06 -04:00
|
|
|
if (IS_ERR(fb)) {
|
|
|
|
ret = PTR_ERR(fb);
|
|
|
|
goto out_unref;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
|
|
|
|
out_unref:
|
|
|
|
for (i = 0; i < n; i++)
|
2020-05-15 10:51:04 +01:00
|
|
|
drm_gem_object_put(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 12:44:06 -04:00
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
|
|
|
|
2017-07-11 10:08:05 -04:00
|
|
|
static struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
|
2025-07-01 12:07:18 +03:00
|
|
|
const struct drm_format_info *info,
|
2015-11-11 19:11:29 +02: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 12:44:06 -04:00
|
|
|
{
|
|
|
|
struct msm_drm_private *priv = dev->dev_private;
|
|
|
|
struct msm_kms *kms = priv->kms;
|
2015-05-05 09:47:57 -04: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 12:44:06 -04:00
|
|
|
const struct msm_format *format;
|
|
|
|
int ret, i, n;
|
|
|
|
|
2024-04-05 12:29:07 +03:00
|
|
|
drm_dbg_state(dev, "create framebuffer: mode_cmd=%p (%dx%d@%p4cc)\n",
|
|
|
|
mode_cmd, mode_cmd->width, mode_cmd->height,
|
|
|
|
&mode_cmd->pixel_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-26 12:44:06 -04:00
|
|
|
|
2019-05-16 12:31:47 +02:00
|
|
|
n = info->num_planes;
|
2024-04-20 07:01:06 +03:00
|
|
|
format = mdp_get_format(kms, mode_cmd->pixel_format,
|
2018-02-13 12:42:44 -05:00
|
|
|
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 12:44:06 -04:00
|
|
|
if (!format) {
|
2024-04-05 12:29:07 +03:00
|
|
|
DRM_DEV_ERROR(dev->dev, "unsupported pixel format: %p4cc\n",
|
|
|
|
&mode_cmd->pixel_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-26 12:44:06 -04:00
|
|
|
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 15:11:35 +01:00
|
|
|
if (n > ARRAY_SIZE(fb->obj)) {
|
2014-11-08 09:20:28 -05: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 12:44:06 -04:00
|
|
|
for (i = 0; i < n; i++) {
|
2019-05-16 12:31:48 +02:00
|
|
|
unsigned int width = mode_cmd->width / (i ? info->hsub : 1);
|
|
|
|
unsigned int height = mode_cmd->height / (i ? info->vsub : 1);
|
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 12:44:06 -04:00
|
|
|
unsigned int min_size;
|
|
|
|
|
|
|
|
min_size = (height - 1) * mode_cmd->pitches[i]
|
2019-05-16 12:31:52 +02:00
|
|
|
+ width * info->cpp[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 12:44:06 -04:00
|
|
|
+ mode_cmd->offsets[i];
|
|
|
|
|
|
|
|
if (bos[i]->size < min_size) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2018-03-30 15:11:35 +01: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 12:44:06 -04:00
|
|
|
}
|
|
|
|
|
2025-07-01 12:07:18 +03:00
|
|
|
drm_helper_mode_fill_fb_struct(dev, fb, info, 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 12:44:06 -04:00
|
|
|
|
|
|
|
ret = drm_framebuffer_init(dev, fb, &msm_framebuffer_funcs);
|
|
|
|
if (ret) {
|
2018-10-20 23:19:26 +05:30
|
|
|
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 12:44:06 -04:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2022-03-04 12:21:45 -08:00
|
|
|
refcount_set(&msm_fb->dirtyfb, 1);
|
|
|
|
|
2024-03-25 14:08:09 -07:00
|
|
|
drm_dbg_state(dev, "create: FB ID: %d (%p)\n", fb->base.id, 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 12:44:06 -04:00
|
|
|
|
|
|
|
return fb;
|
|
|
|
|
|
|
|
fail:
|
2015-05-05 09:47:57 -04: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 12:44:06 -04:00
|
|
|
|
|
|
|
return ERR_PTR(ret);
|
|
|
|
}
|
2017-07-11 10:40:13 -04: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-20 23:19:26 +05:30
|
|
|
DRM_DEV_ERROR(dev->dev, "failed to allocate buffer object\n");
|
2017-07-11 10:40:13 -04:00
|
|
|
return ERR_CAST(bo);
|
|
|
|
}
|
|
|
|
|
2018-11-07 15:35:52 -07:00
|
|
|
msm_gem_object_set_name(bo, "stolenfb");
|
|
|
|
|
2025-07-01 12:07:18 +03:00
|
|
|
fb = msm_framebuffer_init(dev,
|
|
|
|
drm_get_format_info(dev, mode_cmd.pixel_format,
|
|
|
|
mode_cmd.modifier[0]),
|
|
|
|
&mode_cmd, &bo);
|
2017-07-11 10:40:13 -04:00
|
|
|
if (IS_ERR(fb)) {
|
2018-10-20 23:19:26 +05:30
|
|
|
DRM_DEV_ERROR(dev->dev, "failed to allocate fb\n");
|
2017-07-11 10:40:13 -04:00
|
|
|
/* note: if fb creation failed, we can't rely on fb destroy
|
|
|
|
* to unref the bo:
|
|
|
|
*/
|
2020-05-15 10:51:04 +01:00
|
|
|
drm_gem_object_put(bo);
|
2017-07-11 10:40:13 -04:00
|
|
|
return ERR_CAST(fb);
|
|
|
|
}
|
|
|
|
|
|
|
|
return fb;
|
|
|
|
}
|