1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
5 #include <linux/iopoll.h>
7 #include "dpu_hw_mdss.h"
9 #include "dpu_hw_catalog.h"
10 #include "dpu_hw_merge3d.h"
12 #include "dpu_trace.h"
14 #define MERGE_3D_MUX 0x000
15 #define MERGE_3D_MODE 0x004
17 static const struct dpu_merge_3d_cfg
*_merge_3d_offset(enum dpu_merge_3d idx
,
18 const struct dpu_mdss_cfg
*m
,
20 struct dpu_hw_blk_reg_map
*b
)
24 for (i
= 0; i
< m
->merge_3d_count
; i
++) {
25 if (idx
== m
->merge_3d
[i
].id
) {
27 b
->blk_off
= m
->merge_3d
[i
].base
;
28 b
->length
= m
->merge_3d
[i
].len
;
29 b
->hwversion
= m
->hwversion
;
30 b
->log_mask
= DPU_DBG_MASK_PINGPONG
;
31 return &m
->merge_3d
[i
];
35 return ERR_PTR(-EINVAL
);
38 static void dpu_hw_merge_3d_setup_3d_mode(struct dpu_hw_merge_3d
*merge_3d
,
39 enum dpu_3d_blend_mode mode_3d
)
41 struct dpu_hw_blk_reg_map
*c
;
46 if (mode_3d
== BLEND_3D_NONE
) {
47 DPU_REG_WRITE(c
, MERGE_3D_MODE
, 0);
48 DPU_REG_WRITE(c
, MERGE_3D_MUX
, 0);
50 data
= BIT(0) | ((mode_3d
- 1) << 1);
51 DPU_REG_WRITE(c
, MERGE_3D_MODE
, data
);
55 static void _setup_merge_3d_ops(struct dpu_hw_merge_3d
*c
,
56 unsigned long features
)
58 c
->ops
.setup_3d_mode
= dpu_hw_merge_3d_setup_3d_mode
;
61 static struct dpu_hw_blk_ops dpu_hw_ops
;
63 struct dpu_hw_merge_3d
*dpu_hw_merge_3d_init(enum dpu_merge_3d idx
,
65 const struct dpu_mdss_cfg
*m
)
67 struct dpu_hw_merge_3d
*c
;
68 const struct dpu_merge_3d_cfg
*cfg
;
70 c
= kzalloc(sizeof(*c
), GFP_KERNEL
);
72 return ERR_PTR(-ENOMEM
);
74 cfg
= _merge_3d_offset(idx
, m
, addr
, &c
->hw
);
75 if (IS_ERR_OR_NULL(cfg
)) {
77 return ERR_PTR(-EINVAL
);
82 _setup_merge_3d_ops(c
, c
->caps
->features
);
84 dpu_hw_blk_init(&c
->base
, DPU_HW_BLK_MERGE_3D
, idx
, &dpu_hw_ops
);
89 void dpu_hw_merge_3d_destroy(struct dpu_hw_merge_3d
*hw
)
92 dpu_hw_blk_destroy(&hw
->base
);