mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
drm: verisilicon: fill plane's vs_format in atomic_check
Move the conversion from drm_format to vs_format to atomic_check, which is before the point of no return and can properly bail out. Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://patch.msgid.link/20260331060126.1291966-5-zhengxingda@iscas.ac.cn
This commit is contained in:
parent
eae3903e33
commit
c0d650bd0e
|
|
@ -129,17 +129,22 @@ dma_addr_t vs_fb_get_dma_addr(struct drm_framebuffer *fb,
|
|||
|
||||
struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane)
|
||||
{
|
||||
struct vs_plane_state *vs_state;
|
||||
struct vs_plane_state *vs_state, *vs_state_old;
|
||||
|
||||
if (drm_WARN_ON(plane->dev, !plane->state))
|
||||
return NULL;
|
||||
|
||||
vs_state_old = to_vs_plane_state(plane->state);
|
||||
|
||||
vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
|
||||
if (!vs_state)
|
||||
return NULL;
|
||||
|
||||
__drm_atomic_helper_plane_duplicate_state(plane, &vs_state->base);
|
||||
|
||||
memcpy(&vs_state->format, &vs_state_old->format,
|
||||
sizeof(struct vs_format));
|
||||
|
||||
return &vs_state->base;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ struct vs_format {
|
|||
|
||||
struct vs_plane_state {
|
||||
struct drm_plane_state base;
|
||||
|
||||
struct vs_format format;
|
||||
};
|
||||
|
||||
static inline struct vs_plane_state *to_vs_plane_state(struct drm_plane_state *state)
|
||||
|
|
|
|||
|
|
@ -25,17 +25,32 @@ static int vs_primary_plane_atomic_check(struct drm_plane *plane,
|
|||
{
|
||||
struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
|
||||
plane);
|
||||
struct vs_plane_state *new_vs_plane_state = to_vs_plane_state(new_plane_state);
|
||||
struct drm_framebuffer *fb = new_plane_state->fb;
|
||||
struct drm_crtc *crtc = new_plane_state->crtc;
|
||||
struct drm_crtc_state *crtc_state = NULL;
|
||||
int ret;
|
||||
|
||||
if (crtc)
|
||||
crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
|
||||
|
||||
return drm_atomic_helper_check_plane_state(new_plane_state,
|
||||
crtc_state,
|
||||
DRM_PLANE_NO_SCALING,
|
||||
DRM_PLANE_NO_SCALING,
|
||||
false, true);
|
||||
ret = drm_atomic_helper_check_plane_state(new_plane_state,
|
||||
crtc_state,
|
||||
DRM_PLANE_NO_SCALING,
|
||||
DRM_PLANE_NO_SCALING,
|
||||
false, true);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!new_plane_state->visible)
|
||||
return 0;
|
||||
|
||||
ret = drm_format_to_vs_format(fb->format->format,
|
||||
&new_vs_plane_state->format);
|
||||
if (drm_WARN_ON_ONCE(plane->dev, ret))
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vs_primary_plane_commit(struct vs_dc *dc, unsigned int output)
|
||||
|
|
@ -84,11 +99,11 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane,
|
|||
{
|
||||
struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
|
||||
plane);
|
||||
struct vs_plane_state *vs_state = to_vs_plane_state(state);
|
||||
struct drm_framebuffer *fb = state->fb;
|
||||
struct drm_crtc *crtc = state->crtc;
|
||||
struct vs_dc *dc;
|
||||
struct vs_crtc *vcrtc;
|
||||
struct vs_format fmt;
|
||||
unsigned int output;
|
||||
dma_addr_t dma_addr;
|
||||
|
||||
|
|
@ -101,16 +116,15 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane,
|
|||
output = vcrtc->id;
|
||||
dc = vcrtc->dc;
|
||||
|
||||
drm_format_to_vs_format(state->fb->format->format, &fmt);
|
||||
|
||||
regmap_update_bits(dc->regs, VSDC_FB_CONFIG(output),
|
||||
VSDC_FB_CONFIG_FMT_MASK,
|
||||
VSDC_FB_CONFIG_FMT(fmt.color));
|
||||
VSDC_FB_CONFIG_FMT(vs_state->format.color));
|
||||
regmap_update_bits(dc->regs, VSDC_FB_CONFIG(output),
|
||||
VSDC_FB_CONFIG_SWIZZLE_MASK,
|
||||
VSDC_FB_CONFIG_SWIZZLE(fmt.swizzle));
|
||||
VSDC_FB_CONFIG_SWIZZLE(vs_state->format.swizzle));
|
||||
regmap_assign_bits(dc->regs, VSDC_FB_CONFIG(output),
|
||||
VSDC_FB_CONFIG_UV_SWIZZLE_EN, fmt.uv_swizzle);
|
||||
VSDC_FB_CONFIG_UV_SWIZZLE_EN,
|
||||
vs_state->format.uv_swizzle);
|
||||
|
||||
dma_addr = vs_fb_get_dma_addr(fb, &state->src);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user