cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

dpu_hw_merge3d.c (1908B)


      1// SPDX-License-Identifier: GPL-2.0-only
      2/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
      3 */
      4
      5#include <linux/iopoll.h>
      6
      7#include "dpu_hw_mdss.h"
      8#include "dpu_hwio.h"
      9#include "dpu_hw_catalog.h"
     10#include "dpu_hw_merge3d.h"
     11#include "dpu_kms.h"
     12#include "dpu_trace.h"
     13
     14#define MERGE_3D_MUX  0x000
     15#define MERGE_3D_MODE 0x004
     16
     17static const struct dpu_merge_3d_cfg *_merge_3d_offset(enum dpu_merge_3d idx,
     18		const struct dpu_mdss_cfg *m,
     19		void __iomem *addr,
     20		struct dpu_hw_blk_reg_map *b)
     21{
     22	int i;
     23
     24	for (i = 0; i < m->merge_3d_count; i++) {
     25		if (idx == m->merge_3d[i].id) {
     26			b->base_off = addr;
     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];
     32		}
     33	}
     34
     35	return ERR_PTR(-EINVAL);
     36}
     37
     38static void dpu_hw_merge_3d_setup_3d_mode(struct dpu_hw_merge_3d *merge_3d,
     39			enum dpu_3d_blend_mode mode_3d)
     40{
     41	struct dpu_hw_blk_reg_map *c;
     42	u32 data;
     43
     44
     45	c = &merge_3d->hw;
     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);
     49	} else {
     50		data = BIT(0) | ((mode_3d - 1) << 1);
     51		DPU_REG_WRITE(c, MERGE_3D_MODE, data);
     52	}
     53}
     54
     55static void _setup_merge_3d_ops(struct dpu_hw_merge_3d *c,
     56				unsigned long features)
     57{
     58	c->ops.setup_3d_mode = dpu_hw_merge_3d_setup_3d_mode;
     59};
     60
     61struct dpu_hw_merge_3d *dpu_hw_merge_3d_init(enum dpu_merge_3d idx,
     62		void __iomem *addr,
     63		const struct dpu_mdss_cfg *m)
     64{
     65	struct dpu_hw_merge_3d *c;
     66	const struct dpu_merge_3d_cfg *cfg;
     67
     68	c = kzalloc(sizeof(*c), GFP_KERNEL);
     69	if (!c)
     70		return ERR_PTR(-ENOMEM);
     71
     72	cfg = _merge_3d_offset(idx, m, addr, &c->hw);
     73	if (IS_ERR_OR_NULL(cfg)) {
     74		kfree(c);
     75		return ERR_PTR(-EINVAL);
     76	}
     77
     78	c->idx = idx;
     79	c->caps = cfg;
     80	_setup_merge_3d_ops(c, c->caps->features);
     81
     82	return c;
     83}
     84
     85void dpu_hw_merge_3d_destroy(struct dpu_hw_merge_3d *hw)
     86{
     87	kfree(hw);
     88}