1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
3 */
4
5 #include <linux/delay.h>
6 #include "dpu_hwio.h"
7 #include "dpu_hw_ctl.h"
8 #include "dpu_kms.h"
9 #include "dpu_trace.h"
10
11 #define CTL_LAYER(lm) \
12 (((lm) == LM_5) ? (0x024) : (((lm) - LM_0) * 0x004))
13 #define CTL_LAYER_EXT(lm) \
14 (0x40 + (((lm) - LM_0) * 0x004))
15 #define CTL_LAYER_EXT2(lm) \
16 (0x70 + (((lm) - LM_0) * 0x004))
17 #define CTL_LAYER_EXT3(lm) \
18 (0xA0 + (((lm) - LM_0) * 0x004))
19 #define CTL_TOP 0x014
20 #define CTL_FLUSH 0x018
21 #define CTL_START 0x01C
22 #define CTL_PREPARE 0x0d0
23 #define CTL_SW_RESET 0x030
24 #define CTL_LAYER_EXTN_OFFSET 0x40
25 #define CTL_INTF_ACTIVE 0x0F4
26 #define CTL_INTF_FLUSH 0x110
27 #define CTL_INTF_MASTER 0x134
28
29 #define CTL_MIXER_BORDER_OUT BIT(24)
30 #define CTL_FLUSH_MASK_CTL BIT(17)
31
32 #define DPU_REG_RESET_TIMEOUT_US 2000
33 #define INTF_IDX 31
34
_ctl_offset(enum dpu_ctl ctl,const struct dpu_mdss_cfg * m,void __iomem * addr,struct dpu_hw_blk_reg_map * b)35 static const struct dpu_ctl_cfg *_ctl_offset(enum dpu_ctl ctl,
36 const struct dpu_mdss_cfg *m,
37 void __iomem *addr,
38 struct dpu_hw_blk_reg_map *b)
39 {
40 int i;
41
42 for (i = 0; i < m->ctl_count; i++) {
43 if (ctl == m->ctl[i].id) {
44 b->base_off = addr;
45 b->blk_off = m->ctl[i].base;
46 b->length = m->ctl[i].len;
47 b->hwversion = m->hwversion;
48 b->log_mask = DPU_DBG_MASK_CTL;
49 return &m->ctl[i];
50 }
51 }
52 return ERR_PTR(-ENOMEM);
53 }
54
_mixer_stages(const struct dpu_lm_cfg * mixer,int count,enum dpu_lm lm)55 static int _mixer_stages(const struct dpu_lm_cfg *mixer, int count,
56 enum dpu_lm lm)
57 {
58 int i;
59 int stages = -EINVAL;
60
61 for (i = 0; i < count; i++) {
62 if (lm == mixer[i].id) {
63 stages = mixer[i].sblk->maxblendstages;
64 break;
65 }
66 }
67
68 return stages;
69 }
70
dpu_hw_ctl_get_flush_register(struct dpu_hw_ctl * ctx)71 static inline u32 dpu_hw_ctl_get_flush_register(struct dpu_hw_ctl *ctx)
72 {
73 struct dpu_hw_blk_reg_map *c = &ctx->hw;
74
75 return DPU_REG_READ(c, CTL_FLUSH);
76 }
77
dpu_hw_ctl_trigger_start(struct dpu_hw_ctl * ctx)78 static inline void dpu_hw_ctl_trigger_start(struct dpu_hw_ctl *ctx)
79 {
80 trace_dpu_hw_ctl_trigger_start(ctx->pending_flush_mask,
81 dpu_hw_ctl_get_flush_register(ctx));
82 DPU_REG_WRITE(&ctx->hw, CTL_START, 0x1);
83 }
84
dpu_hw_ctl_trigger_pending(struct dpu_hw_ctl * ctx)85 static inline void dpu_hw_ctl_trigger_pending(struct dpu_hw_ctl *ctx)
86 {
87 trace_dpu_hw_ctl_trigger_prepare(ctx->pending_flush_mask,
88 dpu_hw_ctl_get_flush_register(ctx));
89 DPU_REG_WRITE(&ctx->hw, CTL_PREPARE, 0x1);
90 }
91
dpu_hw_ctl_clear_pending_flush(struct dpu_hw_ctl * ctx)92 static inline void dpu_hw_ctl_clear_pending_flush(struct dpu_hw_ctl *ctx)
93 {
94 trace_dpu_hw_ctl_clear_pending_flush(ctx->pending_flush_mask,
95 dpu_hw_ctl_get_flush_register(ctx));
96 ctx->pending_flush_mask = 0x0;
97 }
98
dpu_hw_ctl_update_pending_flush(struct dpu_hw_ctl * ctx,u32 flushbits)99 static inline void dpu_hw_ctl_update_pending_flush(struct dpu_hw_ctl *ctx,
100 u32 flushbits)
101 {
102 trace_dpu_hw_ctl_update_pending_flush(flushbits,
103 ctx->pending_flush_mask);
104 ctx->pending_flush_mask |= flushbits;
105 }
106
dpu_hw_ctl_update_pending_intf_flush(struct dpu_hw_ctl * ctx,u32 flushbits)107 static inline void dpu_hw_ctl_update_pending_intf_flush(struct dpu_hw_ctl *ctx,
108 u32 flushbits)
109 {
110 ctx->pending_intf_flush_mask |= flushbits;
111 }
112
dpu_hw_ctl_get_pending_flush(struct dpu_hw_ctl * ctx)113 static u32 dpu_hw_ctl_get_pending_flush(struct dpu_hw_ctl *ctx)
114 {
115 return ctx->pending_flush_mask;
116 }
117
dpu_hw_ctl_trigger_flush_v1(struct dpu_hw_ctl * ctx)118 static inline void dpu_hw_ctl_trigger_flush_v1(struct dpu_hw_ctl *ctx)
119 {
120
121 if (ctx->pending_flush_mask & BIT(INTF_IDX))
122 DPU_REG_WRITE(&ctx->hw, CTL_INTF_FLUSH,
123 ctx->pending_intf_flush_mask);
124
125 DPU_REG_WRITE(&ctx->hw, CTL_FLUSH, ctx->pending_flush_mask);
126 }
127
dpu_hw_ctl_trigger_flush(struct dpu_hw_ctl * ctx)128 static inline void dpu_hw_ctl_trigger_flush(struct dpu_hw_ctl *ctx)
129 {
130 trace_dpu_hw_ctl_trigger_pending_flush(ctx->pending_flush_mask,
131 dpu_hw_ctl_get_flush_register(ctx));
132 DPU_REG_WRITE(&ctx->hw, CTL_FLUSH, ctx->pending_flush_mask);
133 }
134
dpu_hw_ctl_get_bitmask_sspp(struct dpu_hw_ctl * ctx,enum dpu_sspp sspp)135 static uint32_t dpu_hw_ctl_get_bitmask_sspp(struct dpu_hw_ctl *ctx,
136 enum dpu_sspp sspp)
137 {
138 uint32_t flushbits = 0;
139
140 switch (sspp) {
141 case SSPP_VIG0:
142 flushbits = BIT(0);
143 break;
144 case SSPP_VIG1:
145 flushbits = BIT(1);
146 break;
147 case SSPP_VIG2:
148 flushbits = BIT(2);
149 break;
150 case SSPP_VIG3:
151 flushbits = BIT(18);
152 break;
153 case SSPP_RGB0:
154 flushbits = BIT(3);
155 break;
156 case SSPP_RGB1:
157 flushbits = BIT(4);
158 break;
159 case SSPP_RGB2:
160 flushbits = BIT(5);
161 break;
162 case SSPP_RGB3:
163 flushbits = BIT(19);
164 break;
165 case SSPP_DMA0:
166 flushbits = BIT(11);
167 break;
168 case SSPP_DMA1:
169 flushbits = BIT(12);
170 break;
171 case SSPP_DMA2:
172 flushbits = BIT(24);
173 break;
174 case SSPP_DMA3:
175 flushbits = BIT(25);
176 break;
177 case SSPP_CURSOR0:
178 flushbits = BIT(22);
179 break;
180 case SSPP_CURSOR1:
181 flushbits = BIT(23);
182 break;
183 default:
184 break;
185 }
186
187 return flushbits;
188 }
189
dpu_hw_ctl_get_bitmask_mixer(struct dpu_hw_ctl * ctx,enum dpu_lm lm)190 static uint32_t dpu_hw_ctl_get_bitmask_mixer(struct dpu_hw_ctl *ctx,
191 enum dpu_lm lm)
192 {
193 uint32_t flushbits = 0;
194
195 switch (lm) {
196 case LM_0:
197 flushbits = BIT(6);
198 break;
199 case LM_1:
200 flushbits = BIT(7);
201 break;
202 case LM_2:
203 flushbits = BIT(8);
204 break;
205 case LM_3:
206 flushbits = BIT(9);
207 break;
208 case LM_4:
209 flushbits = BIT(10);
210 break;
211 case LM_5:
212 flushbits = BIT(20);
213 break;
214 default:
215 return -EINVAL;
216 }
217
218 flushbits |= CTL_FLUSH_MASK_CTL;
219
220 return flushbits;
221 }
222
dpu_hw_ctl_get_bitmask_intf(struct dpu_hw_ctl * ctx,u32 * flushbits,enum dpu_intf intf)223 static int dpu_hw_ctl_get_bitmask_intf(struct dpu_hw_ctl *ctx,
224 u32 *flushbits, enum dpu_intf intf)
225 {
226 switch (intf) {
227 case INTF_0:
228 *flushbits |= BIT(31);
229 break;
230 case INTF_1:
231 *flushbits |= BIT(30);
232 break;
233 case INTF_2:
234 *flushbits |= BIT(29);
235 break;
236 case INTF_3:
237 *flushbits |= BIT(28);
238 break;
239 default:
240 return -EINVAL;
241 }
242 return 0;
243 }
244
dpu_hw_ctl_get_bitmask_intf_v1(struct dpu_hw_ctl * ctx,u32 * flushbits,enum dpu_intf intf)245 static int dpu_hw_ctl_get_bitmask_intf_v1(struct dpu_hw_ctl *ctx,
246 u32 *flushbits, enum dpu_intf intf)
247 {
248 *flushbits |= BIT(31);
249 return 0;
250 }
251
dpu_hw_ctl_active_get_bitmask_intf(struct dpu_hw_ctl * ctx,u32 * flushbits,enum dpu_intf intf)252 static int dpu_hw_ctl_active_get_bitmask_intf(struct dpu_hw_ctl *ctx,
253 u32 *flushbits, enum dpu_intf intf)
254 {
255 *flushbits |= BIT(intf - INTF_0);
256 return 0;
257 }
258
dpu_hw_ctl_get_bitmask_dspp(struct dpu_hw_ctl * ctx,enum dpu_dspp dspp)259 static uint32_t dpu_hw_ctl_get_bitmask_dspp(struct dpu_hw_ctl *ctx,
260 enum dpu_dspp dspp)
261 {
262 uint32_t flushbits = 0;
263
264 switch (dspp) {
265 case DSPP_0:
266 flushbits = BIT(13);
267 break;
268 case DSPP_1:
269 flushbits = BIT(14);
270 break;
271 case DSPP_2:
272 flushbits = BIT(15);
273 break;
274 case DSPP_3:
275 flushbits = BIT(21);
276 break;
277 default:
278 return 0;
279 }
280
281 return flushbits;
282 }
283
dpu_hw_ctl_poll_reset_status(struct dpu_hw_ctl * ctx,u32 timeout_us)284 static u32 dpu_hw_ctl_poll_reset_status(struct dpu_hw_ctl *ctx, u32 timeout_us)
285 {
286 struct dpu_hw_blk_reg_map *c = &ctx->hw;
287 ktime_t timeout;
288 u32 status;
289
290 timeout = ktime_add_us(ktime_get(), timeout_us);
291
292 /*
293 * it takes around 30us to have mdp finish resetting its ctl path
294 * poll every 50us so that reset should be completed at 1st poll
295 */
296 do {
297 status = DPU_REG_READ(c, CTL_SW_RESET);
298 status &= 0x1;
299 if (status)
300 usleep_range(20, 50);
301 } while (status && ktime_compare_safe(ktime_get(), timeout) < 0);
302
303 return status;
304 }
305
dpu_hw_ctl_reset_control(struct dpu_hw_ctl * ctx)306 static int dpu_hw_ctl_reset_control(struct dpu_hw_ctl *ctx)
307 {
308 struct dpu_hw_blk_reg_map *c = &ctx->hw;
309
310 pr_debug("issuing hw ctl reset for ctl:%d\n", ctx->idx);
311 DPU_REG_WRITE(c, CTL_SW_RESET, 0x1);
312 if (dpu_hw_ctl_poll_reset_status(ctx, DPU_REG_RESET_TIMEOUT_US))
313 return -EINVAL;
314
315 return 0;
316 }
317
dpu_hw_ctl_wait_reset_status(struct dpu_hw_ctl * ctx)318 static int dpu_hw_ctl_wait_reset_status(struct dpu_hw_ctl *ctx)
319 {
320 struct dpu_hw_blk_reg_map *c = &ctx->hw;
321 u32 status;
322
323 status = DPU_REG_READ(c, CTL_SW_RESET);
324 status &= 0x01;
325 if (!status)
326 return 0;
327
328 pr_debug("hw ctl reset is set for ctl:%d\n", ctx->idx);
329 if (dpu_hw_ctl_poll_reset_status(ctx, DPU_REG_RESET_TIMEOUT_US)) {
330 pr_err("hw recovery is not complete for ctl:%d\n", ctx->idx);
331 return -EINVAL;
332 }
333
334 return 0;
335 }
336
dpu_hw_ctl_clear_all_blendstages(struct dpu_hw_ctl * ctx)337 static void dpu_hw_ctl_clear_all_blendstages(struct dpu_hw_ctl *ctx)
338 {
339 struct dpu_hw_blk_reg_map *c = &ctx->hw;
340 int i;
341
342 for (i = 0; i < ctx->mixer_count; i++) {
343 enum dpu_lm mixer_id = ctx->mixer_hw_caps[i].id;
344
345 DPU_REG_WRITE(c, CTL_LAYER(mixer_id), 0);
346 DPU_REG_WRITE(c, CTL_LAYER_EXT(mixer_id), 0);
347 DPU_REG_WRITE(c, CTL_LAYER_EXT2(mixer_id), 0);
348 DPU_REG_WRITE(c, CTL_LAYER_EXT3(mixer_id), 0);
349 }
350 }
351
dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl * ctx,enum dpu_lm lm,struct dpu_hw_stage_cfg * stage_cfg)352 static void dpu_hw_ctl_setup_blendstage(struct dpu_hw_ctl *ctx,
353 enum dpu_lm lm, struct dpu_hw_stage_cfg *stage_cfg)
354 {
355 struct dpu_hw_blk_reg_map *c = &ctx->hw;
356 u32 mixercfg = 0, mixercfg_ext = 0, mix, ext;
357 u32 mixercfg_ext2 = 0, mixercfg_ext3 = 0;
358 int i, j;
359 int stages;
360 int pipes_per_stage;
361
362 stages = _mixer_stages(ctx->mixer_hw_caps, ctx->mixer_count, lm);
363 if (stages < 0)
364 return;
365
366 if (test_bit(DPU_MIXER_SOURCESPLIT,
367 &ctx->mixer_hw_caps->features))
368 pipes_per_stage = PIPES_PER_STAGE;
369 else
370 pipes_per_stage = 1;
371
372 mixercfg = CTL_MIXER_BORDER_OUT; /* always set BORDER_OUT */
373
374 if (!stage_cfg)
375 goto exit;
376
377 for (i = 0; i <= stages; i++) {
378 /* overflow to ext register if 'i + 1 > 7' */
379 mix = (i + 1) & 0x7;
380 ext = i >= 7;
381
382 for (j = 0 ; j < pipes_per_stage; j++) {
383 enum dpu_sspp_multirect_index rect_index =
384 stage_cfg->multirect_index[i][j];
385
386 switch (stage_cfg->stage[i][j]) {
387 case SSPP_VIG0:
388 if (rect_index == DPU_SSPP_RECT_1) {
389 mixercfg_ext3 |= ((i + 1) & 0xF) << 0;
390 } else {
391 mixercfg |= mix << 0;
392 mixercfg_ext |= ext << 0;
393 }
394 break;
395 case SSPP_VIG1:
396 if (rect_index == DPU_SSPP_RECT_1) {
397 mixercfg_ext3 |= ((i + 1) & 0xF) << 4;
398 } else {
399 mixercfg |= mix << 3;
400 mixercfg_ext |= ext << 2;
401 }
402 break;
403 case SSPP_VIG2:
404 if (rect_index == DPU_SSPP_RECT_1) {
405 mixercfg_ext3 |= ((i + 1) & 0xF) << 8;
406 } else {
407 mixercfg |= mix << 6;
408 mixercfg_ext |= ext << 4;
409 }
410 break;
411 case SSPP_VIG3:
412 if (rect_index == DPU_SSPP_RECT_1) {
413 mixercfg_ext3 |= ((i + 1) & 0xF) << 12;
414 } else {
415 mixercfg |= mix << 26;
416 mixercfg_ext |= ext << 6;
417 }
418 break;
419 case SSPP_RGB0:
420 mixercfg |= mix << 9;
421 mixercfg_ext |= ext << 8;
422 break;
423 case SSPP_RGB1:
424 mixercfg |= mix << 12;
425 mixercfg_ext |= ext << 10;
426 break;
427 case SSPP_RGB2:
428 mixercfg |= mix << 15;
429 mixercfg_ext |= ext << 12;
430 break;
431 case SSPP_RGB3:
432 mixercfg |= mix << 29;
433 mixercfg_ext |= ext << 14;
434 break;
435 case SSPP_DMA0:
436 if (rect_index == DPU_SSPP_RECT_1) {
437 mixercfg_ext2 |= ((i + 1) & 0xF) << 8;
438 } else {
439 mixercfg |= mix << 18;
440 mixercfg_ext |= ext << 16;
441 }
442 break;
443 case SSPP_DMA1:
444 if (rect_index == DPU_SSPP_RECT_1) {
445 mixercfg_ext2 |= ((i + 1) & 0xF) << 12;
446 } else {
447 mixercfg |= mix << 21;
448 mixercfg_ext |= ext << 18;
449 }
450 break;
451 case SSPP_DMA2:
452 if (rect_index == DPU_SSPP_RECT_1) {
453 mixercfg_ext2 |= ((i + 1) & 0xF) << 16;
454 } else {
455 mix |= (i + 1) & 0xF;
456 mixercfg_ext2 |= mix << 0;
457 }
458 break;
459 case SSPP_DMA3:
460 if (rect_index == DPU_SSPP_RECT_1) {
461 mixercfg_ext2 |= ((i + 1) & 0xF) << 20;
462 } else {
463 mix |= (i + 1) & 0xF;
464 mixercfg_ext2 |= mix << 4;
465 }
466 break;
467 case SSPP_CURSOR0:
468 mixercfg_ext |= ((i + 1) & 0xF) << 20;
469 break;
470 case SSPP_CURSOR1:
471 mixercfg_ext |= ((i + 1) & 0xF) << 26;
472 break;
473 default:
474 break;
475 }
476 }
477 }
478
479 exit:
480 DPU_REG_WRITE(c, CTL_LAYER(lm), mixercfg);
481 DPU_REG_WRITE(c, CTL_LAYER_EXT(lm), mixercfg_ext);
482 DPU_REG_WRITE(c, CTL_LAYER_EXT2(lm), mixercfg_ext2);
483 DPU_REG_WRITE(c, CTL_LAYER_EXT3(lm), mixercfg_ext3);
484 }
485
486
dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl * ctx,struct dpu_hw_intf_cfg * cfg)487 static void dpu_hw_ctl_intf_cfg_v1(struct dpu_hw_ctl *ctx,
488 struct dpu_hw_intf_cfg *cfg)
489 {
490 struct dpu_hw_blk_reg_map *c = &ctx->hw;
491 u32 intf_active = 0;
492 u32 mode_sel = 0;
493
494 if (cfg->intf_mode_sel == DPU_CTL_MODE_SEL_CMD)
495 mode_sel |= BIT(17);
496
497 intf_active = DPU_REG_READ(c, CTL_INTF_ACTIVE);
498 intf_active |= BIT(cfg->intf - INTF_0);
499
500 DPU_REG_WRITE(c, CTL_TOP, mode_sel);
501 DPU_REG_WRITE(c, CTL_INTF_ACTIVE, intf_active);
502 }
503
dpu_hw_ctl_intf_cfg(struct dpu_hw_ctl * ctx,struct dpu_hw_intf_cfg * cfg)504 static void dpu_hw_ctl_intf_cfg(struct dpu_hw_ctl *ctx,
505 struct dpu_hw_intf_cfg *cfg)
506 {
507 struct dpu_hw_blk_reg_map *c = &ctx->hw;
508 u32 intf_cfg = 0;
509
510 intf_cfg |= (cfg->intf & 0xF) << 4;
511
512 if (cfg->mode_3d) {
513 intf_cfg |= BIT(19);
514 intf_cfg |= (cfg->mode_3d - 0x1) << 20;
515 }
516
517 switch (cfg->intf_mode_sel) {
518 case DPU_CTL_MODE_SEL_VID:
519 intf_cfg &= ~BIT(17);
520 intf_cfg &= ~(0x3 << 15);
521 break;
522 case DPU_CTL_MODE_SEL_CMD:
523 intf_cfg |= BIT(17);
524 intf_cfg |= ((cfg->stream_sel & 0x3) << 15);
525 break;
526 default:
527 pr_err("unknown interface type %d\n", cfg->intf_mode_sel);
528 return;
529 }
530
531 DPU_REG_WRITE(c, CTL_TOP, intf_cfg);
532 }
533
_setup_ctl_ops(struct dpu_hw_ctl_ops * ops,unsigned long cap)534 static void _setup_ctl_ops(struct dpu_hw_ctl_ops *ops,
535 unsigned long cap)
536 {
537 if (cap & BIT(DPU_CTL_ACTIVE_CFG)) {
538 ops->trigger_flush = dpu_hw_ctl_trigger_flush_v1;
539 ops->setup_intf_cfg = dpu_hw_ctl_intf_cfg_v1;
540 ops->get_bitmask_intf = dpu_hw_ctl_get_bitmask_intf_v1;
541 ops->get_bitmask_active_intf =
542 dpu_hw_ctl_active_get_bitmask_intf;
543 ops->update_pending_intf_flush =
544 dpu_hw_ctl_update_pending_intf_flush;
545 } else {
546 ops->trigger_flush = dpu_hw_ctl_trigger_flush;
547 ops->setup_intf_cfg = dpu_hw_ctl_intf_cfg;
548 ops->get_bitmask_intf = dpu_hw_ctl_get_bitmask_intf;
549 }
550 ops->clear_pending_flush = dpu_hw_ctl_clear_pending_flush;
551 ops->update_pending_flush = dpu_hw_ctl_update_pending_flush;
552 ops->get_pending_flush = dpu_hw_ctl_get_pending_flush;
553 ops->get_flush_register = dpu_hw_ctl_get_flush_register;
554 ops->trigger_start = dpu_hw_ctl_trigger_start;
555 ops->trigger_pending = dpu_hw_ctl_trigger_pending;
556 ops->reset = dpu_hw_ctl_reset_control;
557 ops->wait_reset_status = dpu_hw_ctl_wait_reset_status;
558 ops->clear_all_blendstages = dpu_hw_ctl_clear_all_blendstages;
559 ops->setup_blendstage = dpu_hw_ctl_setup_blendstage;
560 ops->get_bitmask_sspp = dpu_hw_ctl_get_bitmask_sspp;
561 ops->get_bitmask_mixer = dpu_hw_ctl_get_bitmask_mixer;
562 ops->get_bitmask_dspp = dpu_hw_ctl_get_bitmask_dspp;
563 };
564
565 static struct dpu_hw_blk_ops dpu_hw_ops;
566
dpu_hw_ctl_init(enum dpu_ctl idx,void __iomem * addr,const struct dpu_mdss_cfg * m)567 struct dpu_hw_ctl *dpu_hw_ctl_init(enum dpu_ctl idx,
568 void __iomem *addr,
569 const struct dpu_mdss_cfg *m)
570 {
571 struct dpu_hw_ctl *c;
572 const struct dpu_ctl_cfg *cfg;
573
574 c = kzalloc(sizeof(*c), GFP_KERNEL);
575 if (!c)
576 return ERR_PTR(-ENOMEM);
577
578 cfg = _ctl_offset(idx, m, addr, &c->hw);
579 if (IS_ERR_OR_NULL(cfg)) {
580 kfree(c);
581 pr_err("failed to create dpu_hw_ctl %d\n", idx);
582 return ERR_PTR(-EINVAL);
583 }
584
585 c->caps = cfg;
586 _setup_ctl_ops(&c->ops, c->caps->features);
587 c->idx = idx;
588 c->mixer_count = m->mixer_count;
589 c->mixer_hw_caps = m->mixer;
590
591 dpu_hw_blk_init(&c->base, DPU_HW_BLK_CTL, idx, &dpu_hw_ops);
592
593 return c;
594 }
595
dpu_hw_ctl_destroy(struct dpu_hw_ctl * ctx)596 void dpu_hw_ctl_destroy(struct dpu_hw_ctl *ctx)
597 {
598 if (ctx)
599 dpu_hw_blk_destroy(&ctx->base);
600 kfree(ctx);
601 }
602