1 /*
2 * Copyright (C) 2016 Rockchip Electronics Co.Ltd
3 * Authors:
4 * Zhiqin Wei <wzq@rock-chips.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 */
12
13 #ifndef _rk_drm_rga_
14 #define _rk_drm_rga_
15
16 #include <stdint.h>
17 #include <sys/cdefs.h>
18 #include "rga.h"
19 #include "RockchipRgaMacro.h"
20
21 /*****************************************************************************/
22
23 /* for compatibility */
24 #define DRM_RGA_MODULE_API_VERSION HWC_MODULE_API_VERSION_0_1
25 #define DRM_RGA_DEVICE_API_VERSION HWC_DEVICE_API_VERSION_0_1
26 #define DRM_RGA_API_VERSION HWC_DEVICE_API_VERSION
27
28 #define DRM_RGA_TRANSFORM_ROT_MASK 0x0000000F
29 #define DRM_RGA_TRANSFORM_ROT_0 0x00000000
30 #define DRM_RGA_TRANSFORM_ROT_90 HAL_TRANSFORM_ROT_90
31 #define DRM_RGA_TRANSFORM_ROT_180 HAL_TRANSFORM_ROT_180
32 #define DRM_RGA_TRANSFORM_ROT_270 HAL_TRANSFORM_ROT_270
33
34 #define DRM_RGA_TRANSFORM_FLIP_MASK 0x00000003
35 #define DRM_RGA_TRANSFORM_FLIP_H HAL_TRANSFORM_FLIP_H
36 #define DRM_RGA_TRANSFORM_FLIP_V HAL_TRANSFORM_FLIP_V
37
38 enum {
39 AWIDTH = 0,
40 AHEIGHT,
41 ASTRIDE,
42 AFORMAT,
43 ASIZE,
44 ATYPE,
45 };
46 /*****************************************************************************/
47
48
49 typedef struct bo {
50 int fd;
51 void *ptr;
52 size_t size;
53 size_t offset;
54 size_t pitch;
55 unsigned handle;
56 }bo_t;
57
58 /*
59 @value size: user not need care about.For avoid read/write out of memory
60 */
61 typedef struct rga_rect {
62 int xoffset;
63 int yoffset;
64 int width;
65 int height;
66 int wstride;
67 int hstride;
68 int format;
69 int size;
70 } rga_rect_t;
71
72 /*
73 @value fd: use fd to share memory, it can be ion shard fd,and dma fd.
74 @value virAddr:userspace address
75 @value phyAddr:use phy address
76 @value hnd: use buffer_handle_t
77 */
78 typedef struct rga_info {
79 int fd;
80 void *virAddr;
81 void *phyAddr;
82 unsigned hnd;
83 int format;
84 rga_rect_t rect;
85 unsigned int blend;
86 int bufferSize;
87 int rotation;
88 int color;
89 int testLog;
90 int mmuFlag;
91 int scale_mode;
92 int reserve[124];
93 } rga_info_t;
94
95
96 typedef struct drm_rga {
97 rga_rect_t src;
98 rga_rect_t dst;
99 } drm_rga_t;
100
101 /*
102 @fun rga_set_rect:For use to set the rects esayly
103
104 @param rect:The rect user want to set,like setting the src rect:
105 drm_rga_t rects;
106 rga_set_rect(rects.src,0,0,1920,1080,1920,NV12);
107 mean to set the src rect to the value.
108 */
rga_set_rect(rga_rect_t * rect,int x,int y,int w,int h,int sw,int sh,int f)109 static inline int rga_set_rect(rga_rect_t *rect,
110 int x, int y, int w, int h, int sw, int sh, int f)
111 {
112 if (!rect)
113 return -EINVAL;
114
115 rect->xoffset = x;
116 rect->yoffset = y;
117 rect->width = w;
118 rect->height = h;
119 rect->wstride = sw;
120 rect->hstride = sh;
121 rect->format = f;
122
123 return 0;
124 }
125
rga_set_rotation(rga_info_t * info,int angle)126 static inline void rga_set_rotation(rga_info_t *info, int angle)
127 {
128 if (angle == 90)
129 info->rotation = HAL_TRANSFORM_ROT_90;
130 else if (angle == 180)
131 info->rotation = HAL_TRANSFORM_ROT_180;
132 else if (angle == 270)
133 info->rotation = HAL_TRANSFORM_ROT_270;
134 }
135 /*****************************************************************************/
136
137 #endif
138