Skip to content

Commit aae8736

Browse files
Jessica Zhanglumag
authored andcommitted
drm/msm/dpu: Add dpu_hw_cwb abstraction for CWB block
The CWB mux has its own registers and set of operations. Add dpu_hw_cwb abstraction to allow driver to configure the CWB mux. Reviewed-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Jessica Zhang <[email protected]> Signed-off-by: Dmitry Baryshkov <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/629254/ Link: https://lore.kernel.org/r/[email protected] [DB: added #include <linux/bitfield.h>] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 675c1ed commit aae8736

File tree

4 files changed

+150
-1
lines changed

4 files changed

+150
-1
lines changed

drivers/gpu/drm/msm/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ msm-display-$(CONFIG_DRM_MSM_DPU) += \
7878
disp/dpu1/dpu_hw_catalog.o \
7979
disp/dpu1/dpu_hw_cdm.o \
8080
disp/dpu1/dpu_hw_ctl.o \
81+
disp/dpu1/dpu_hw_cwb.o \
8182
disp/dpu1/dpu_hw_dsc.o \
8283
disp/dpu1/dpu_hw_dsc_1_2.o \
8384
disp/dpu1/dpu_hw_interrupts.o \
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved
4+
*/
5+
6+
#include <drm/drm_managed.h>
7+
#include "dpu_hw_cwb.h"
8+
9+
#include <linux/bitfield.h>
10+
11+
#define CWB_MUX 0x000
12+
#define CWB_MODE 0x004
13+
14+
/* CWB mux block bit definitions */
15+
#define CWB_MUX_MASK GENMASK(3, 0)
16+
#define CWB_MODE_MASK GENMASK(2, 0)
17+
18+
static void dpu_hw_cwb_config(struct dpu_hw_cwb *ctx,
19+
struct dpu_hw_cwb_setup_cfg *cwb_cfg)
20+
{
21+
struct dpu_hw_blk_reg_map *c = &ctx->hw;
22+
int cwb_mux_cfg = 0xF;
23+
enum dpu_pingpong pp;
24+
enum cwb_mode_input input;
25+
26+
if (!cwb_cfg)
27+
return;
28+
29+
input = cwb_cfg->input;
30+
pp = cwb_cfg->pp_idx;
31+
32+
if (input >= INPUT_MODE_MAX)
33+
return;
34+
35+
/*
36+
* The CWB_MUX register takes the pingpong index for the real-time
37+
* display
38+
*/
39+
if ((pp != PINGPONG_NONE) && (pp < PINGPONG_MAX))
40+
cwb_mux_cfg = FIELD_PREP(CWB_MUX_MASK, pp - PINGPONG_0);
41+
42+
input = FIELD_PREP(CWB_MODE_MASK, input);
43+
44+
DPU_REG_WRITE(c, CWB_MUX, cwb_mux_cfg);
45+
DPU_REG_WRITE(c, CWB_MODE, input);
46+
}
47+
48+
/**
49+
* dpu_hw_cwb_init() - Initializes the writeback hw driver object with cwb.
50+
* @dev: Corresponding device for devres management
51+
* @cfg: wb_path catalog entry for which driver object is required
52+
* @addr: mapped register io address of MDP
53+
* Return: Error code or allocated dpu_hw_wb context
54+
*/
55+
struct dpu_hw_cwb *dpu_hw_cwb_init(struct drm_device *dev,
56+
const struct dpu_cwb_cfg *cfg,
57+
void __iomem *addr)
58+
{
59+
struct dpu_hw_cwb *c;
60+
61+
if (!addr)
62+
return ERR_PTR(-EINVAL);
63+
64+
c = drmm_kzalloc(dev, sizeof(*c), GFP_KERNEL);
65+
if (!c)
66+
return ERR_PTR(-ENOMEM);
67+
68+
c->hw.blk_addr = addr + cfg->base;
69+
c->hw.log_mask = DPU_DBG_MASK_CWB;
70+
71+
c->idx = cfg->id;
72+
c->ops.config_cwb = dpu_hw_cwb_config;
73+
74+
return c;
75+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved
4+
*/
5+
6+
#ifndef _DPU_HW_CWB_H
7+
#define _DPU_HW_CWB_H
8+
9+
#include "dpu_hw_util.h"
10+
11+
struct dpu_hw_cwb;
12+
13+
enum cwb_mode_input {
14+
INPUT_MODE_LM_OUT,
15+
INPUT_MODE_DSPP_OUT,
16+
INPUT_MODE_MAX
17+
};
18+
19+
/**
20+
* struct dpu_hw_cwb_setup_cfg : Describes configuration for CWB mux
21+
* @pp_idx: Index of the real-time pinpong that the CWB mux will
22+
* feed the CWB mux
23+
* @input: Input tap point
24+
*/
25+
struct dpu_hw_cwb_setup_cfg {
26+
enum dpu_pingpong pp_idx;
27+
enum cwb_mode_input input;
28+
};
29+
30+
/**
31+
*
32+
* struct dpu_hw_cwb_ops : Interface to the cwb hw driver functions
33+
* @config_cwb: configure CWB mux
34+
*/
35+
struct dpu_hw_cwb_ops {
36+
void (*config_cwb)(struct dpu_hw_cwb *ctx,
37+
struct dpu_hw_cwb_setup_cfg *cwb_cfg);
38+
};
39+
40+
/**
41+
* struct dpu_hw_cwb : CWB mux driver object
42+
* @base: Hardware block base structure
43+
* @hw: Block hardware details
44+
* @idx: CWB index
45+
* @ops: handle to operations possible for this CWB
46+
*/
47+
struct dpu_hw_cwb {
48+
struct dpu_hw_blk base;
49+
struct dpu_hw_blk_reg_map hw;
50+
51+
enum dpu_cwb idx;
52+
53+
struct dpu_hw_cwb_ops ops;
54+
};
55+
56+
/**
57+
* dpu_hw_cwb - convert base object dpu_hw_base to container
58+
* @hw: Pointer to base hardware block
59+
* return: Pointer to hardware block container
60+
*/
61+
static inline struct dpu_hw_cwb *to_dpu_hw_cwb(struct dpu_hw_blk *hw)
62+
{
63+
return container_of(hw, struct dpu_hw_cwb, base);
64+
}
65+
66+
struct dpu_hw_cwb *dpu_hw_cwb_init(struct drm_device *dev,
67+
const struct dpu_cwb_cfg *cfg,
68+
void __iomem *addr);
69+
70+
#endif /*_DPU_HW_CWB_H */

drivers/gpu/drm/msm/disp/dpu1/dpu_hw_mdss.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
2-
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
2+
/*
3+
* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
35
*/
46

57
#ifndef _DPU_HW_MDSS_H
@@ -350,6 +352,7 @@ struct dpu_mdss_color {
350352
#define DPU_DBG_MASK_DSPP (1 << 10)
351353
#define DPU_DBG_MASK_DSC (1 << 11)
352354
#define DPU_DBG_MASK_CDM (1 << 12)
355+
#define DPU_DBG_MASK_CWB (1 << 13)
353356

354357
/**
355358
* struct dpu_hw_tear_check - Struct contains parameters to configure

0 commit comments

Comments
 (0)