Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 *
  3 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  4 * Author: Rob Clark <rob@ti.com>
  5 *         Andy Gross <andy.gross@ti.com>
  6 *
  7 * This program is free software; you can redistribute it and/or
  8 * modify it under the terms of the GNU General Public License as
  9 * published by the Free Software Foundation version 2.
 10 *
 11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
 12 * kind, whether express or implied; without even the implied warranty
 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 * GNU General Public License for more details.
 15 */
 16#ifndef OMAP_DMM_TILER_H
 17#define OMAP_DMM_TILER_H
 18
 19#include "omap_drv.h"
 20#include "tcm.h"
 21
 22enum tiler_fmt {
 23	TILFMT_8BIT = 0,
 24	TILFMT_16BIT,
 25	TILFMT_32BIT,
 26	TILFMT_PAGE,
 27	TILFMT_NFORMATS
 28};
 29
 30struct pat_area {
 31	u32 x0:8;
 32	u32 y0:8;
 33	u32 x1:8;
 34	u32 y1:8;
 35};
 36
 37struct tiler_block {
 38	struct list_head alloc_node;	/* node for global block list */
 39	struct tcm_area area;		/* area */
 40	enum tiler_fmt fmt;		/* format */
 41};
 42
 43/* bits representing the same slot in DMM-TILER hw-block */
 44#define SLOT_WIDTH_BITS         6
 45#define SLOT_HEIGHT_BITS        6
 46
 47/* bits reserved to describe coordinates in DMM-TILER hw-block */
 48#define CONT_WIDTH_BITS         14
 49#define CONT_HEIGHT_BITS        13
 50
 51/* calculated constants */
 52#define TILER_PAGE              (1 << (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS))
 53#define TILER_WIDTH             (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS))
 54#define TILER_HEIGHT            (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS))
 55
 56/*
 57Table 15-11. Coding and Description of TILER Orientations
 58S Y X	Description				Alternate description
 590 0 0	0-degree view				Natural view
 600 0 1	0-degree view with vertical mirror 	180-degree view with horizontal mirror
 610 1 0	0-degree view with horizontal mirror 	180-degree view with vertical mirror
 620 1 1	180-degree view
 631 0 0	90-degree view with vertical mirror	270-degree view with horizontal mirror
 641 0 1	270-degree view
 651 1 0	90-degree view
 661 1 1	90-degree view with horizontal mirror	270-degree view with vertical mirror
 67 */
 68#define MASK_XY_FLIP		(1 << 31)
 69#define MASK_Y_INVERT		(1 << 30)
 70#define MASK_X_INVERT		(1 << 29)
 71#define SHIFT_ACC_MODE		27
 72#define MASK_ACC_MODE		3
 73
 74#define MASK(bits) ((1 << (bits)) - 1)
 75
 76#define TILVIEW_8BIT    0x60000000u
 77#define TILVIEW_16BIT   (TILVIEW_8BIT  + VIEW_SIZE)
 78#define TILVIEW_32BIT   (TILVIEW_16BIT + VIEW_SIZE)
 79#define TILVIEW_PAGE    (TILVIEW_32BIT + VIEW_SIZE)
 80#define TILVIEW_END     (TILVIEW_PAGE  + VIEW_SIZE)
 81
 82/* create tsptr by adding view orientation and access mode */
 83#define TIL_ADDR(x, orient, a)\
 84	((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE))
 85
 86#ifdef CONFIG_DEBUG_FS
 87int tiler_map_show(struct seq_file *s, void *arg);
 88#endif
 89
 90/* pin/unpin */
 91int tiler_pin(struct tiler_block *block, struct page **pages,
 92		uint32_t npages, uint32_t roll, bool wait);
 93int tiler_unpin(struct tiler_block *block);
 94
 95/* reserve/release */
 96struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w, uint16_t h,
 97				uint16_t align);
 98struct tiler_block *tiler_reserve_1d(size_t size);
 99int tiler_release(struct tiler_block *block);
100
101/* utilities */
102dma_addr_t tiler_ssptr(struct tiler_block *block);
103dma_addr_t tiler_tsptr(struct tiler_block *block, uint32_t orient,
104		uint32_t x, uint32_t y);
105uint32_t tiler_stride(enum tiler_fmt fmt, uint32_t orient);
106size_t tiler_size(enum tiler_fmt fmt, uint16_t w, uint16_t h);
107size_t tiler_vsize(enum tiler_fmt fmt, uint16_t w, uint16_t h);
108void tiler_align(enum tiler_fmt fmt, uint16_t *w, uint16_t *h);
109uint32_t tiler_get_cpu_cache_flags(void);
110bool dmm_is_available(void);
111
112extern struct platform_driver omap_dmm_driver;
113
114/* GEM bo flags -> tiler fmt */
115static inline enum tiler_fmt gem2fmt(uint32_t flags)
116{
117	switch (flags & OMAP_BO_TILED) {
118	case OMAP_BO_TILED_8:
119		return TILFMT_8BIT;
120	case OMAP_BO_TILED_16:
121		return TILFMT_16BIT;
122	case OMAP_BO_TILED_32:
123		return TILFMT_32BIT;
124	default:
125		return TILFMT_PAGE;
126	}
127}
128
129static inline bool validfmt(enum tiler_fmt fmt)
130{
131	switch (fmt) {
132	case TILFMT_8BIT:
133	case TILFMT_16BIT:
134	case TILFMT_32BIT:
135	case TILFMT_PAGE:
136		return true;
137	default:
138		return false;
139	}
140}
141
142#endif
v6.8
  1/* SPDX-License-Identifier: GPL-2.0-only */
  2/*
  3 * Copyright (C) 2011 Texas Instruments Incorporated - https://www.ti.com/
 
  4 * Author: Rob Clark <rob@ti.com>
  5 *         Andy Gross <andy.gross@ti.com>
 
 
 
 
 
 
 
 
 
  6 */
  7#ifndef OMAP_DMM_TILER_H
  8#define OMAP_DMM_TILER_H
  9
 10#include "omap_drv.h"
 11#include "tcm.h"
 12
 13enum tiler_fmt {
 14	TILFMT_8BIT = 0,
 15	TILFMT_16BIT,
 16	TILFMT_32BIT,
 17	TILFMT_PAGE,
 18	TILFMT_NFORMATS
 19};
 20
 21struct pat_area {
 22	u32 x0:8;
 23	u32 y0:8;
 24	u32 x1:8;
 25	u32 y1:8;
 26};
 27
 28struct tiler_block {
 29	struct list_head alloc_node;	/* node for global block list */
 30	struct tcm_area area;		/* area */
 31	enum tiler_fmt fmt;		/* format */
 32};
 33
 34/* bits representing the same slot in DMM-TILER hw-block */
 35#define SLOT_WIDTH_BITS         6
 36#define SLOT_HEIGHT_BITS        6
 37
 38/* bits reserved to describe coordinates in DMM-TILER hw-block */
 39#define CONT_WIDTH_BITS         14
 40#define CONT_HEIGHT_BITS        13
 41
 42/* calculated constants */
 43#define TILER_PAGE              (1 << (SLOT_WIDTH_BITS + SLOT_HEIGHT_BITS))
 44#define TILER_WIDTH             (1 << (CONT_WIDTH_BITS - SLOT_WIDTH_BITS))
 45#define TILER_HEIGHT            (1 << (CONT_HEIGHT_BITS - SLOT_HEIGHT_BITS))
 46
 47/*
 48Table 15-11. Coding and Description of TILER Orientations
 49S Y X	Description				Alternate description
 500 0 0	0-degree view				Natural view
 510 0 1	0-degree view with vertical mirror 	180-degree view with horizontal mirror
 520 1 0	0-degree view with horizontal mirror 	180-degree view with vertical mirror
 530 1 1	180-degree view
 541 0 0	90-degree view with vertical mirror	270-degree view with horizontal mirror
 551 0 1	270-degree view
 561 1 0	90-degree view
 571 1 1	90-degree view with horizontal mirror	270-degree view with vertical mirror
 58 */
 59#define MASK_XY_FLIP		(1 << 31)
 60#define MASK_Y_INVERT		(1 << 30)
 61#define MASK_X_INVERT		(1 << 29)
 62#define SHIFT_ACC_MODE		27
 63#define MASK_ACC_MODE		3
 64
 65#define MASK(bits) ((1 << (bits)) - 1)
 66
 67#define TILVIEW_8BIT    0x60000000u
 68#define TILVIEW_16BIT   (TILVIEW_8BIT  + VIEW_SIZE)
 69#define TILVIEW_32BIT   (TILVIEW_16BIT + VIEW_SIZE)
 70#define TILVIEW_PAGE    (TILVIEW_32BIT + VIEW_SIZE)
 71#define TILVIEW_END     (TILVIEW_PAGE  + VIEW_SIZE)
 72
 73/* create tsptr by adding view orientation and access mode */
 74#define TIL_ADDR(x, orient, a)\
 75	((u32) (x) | (orient) | ((a) << SHIFT_ACC_MODE))
 76
 77#ifdef CONFIG_DEBUG_FS
 78int tiler_map_show(struct seq_file *s, void *arg);
 79#endif
 80
 81/* pin/unpin */
 82int tiler_pin(struct tiler_block *block, struct page **pages,
 83		u32 npages, u32 roll, bool wait);
 84int tiler_unpin(struct tiler_block *block);
 85
 86/* reserve/release */
 87struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, u16 w, u16 h,
 88				u16 align);
 89struct tiler_block *tiler_reserve_1d(size_t size);
 90int tiler_release(struct tiler_block *block);
 91
 92/* utilities */
 93dma_addr_t tiler_ssptr(struct tiler_block *block);
 94dma_addr_t tiler_tsptr(struct tiler_block *block, u32 orient,
 95		u32 x, u32 y);
 96u32 tiler_stride(enum tiler_fmt fmt, u32 orient);
 97size_t tiler_size(enum tiler_fmt fmt, u16 w, u16 h);
 98size_t tiler_vsize(enum tiler_fmt fmt, u16 w, u16 h);
 99void tiler_align(enum tiler_fmt fmt, u16 *w, u16 *h);
100u32 tiler_get_cpu_cache_flags(void);
101bool dmm_is_available(void);
102
103extern struct platform_driver omap_dmm_driver;
104
105/* GEM bo flags -> tiler fmt */
106static inline enum tiler_fmt gem2fmt(u32 flags)
107{
108	switch (flags & OMAP_BO_TILED_MASK) {
109	case OMAP_BO_TILED_8:
110		return TILFMT_8BIT;
111	case OMAP_BO_TILED_16:
112		return TILFMT_16BIT;
113	case OMAP_BO_TILED_32:
114		return TILFMT_32BIT;
115	default:
116		return TILFMT_PAGE;
117	}
118}
119
120static inline bool validfmt(enum tiler_fmt fmt)
121{
122	switch (fmt) {
123	case TILFMT_8BIT:
124	case TILFMT_16BIT:
125	case TILFMT_32BIT:
126	case TILFMT_PAGE:
127		return true;
128	default:
129		return false;
130	}
131}
132
133#endif