1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 2010 - 2015, Intel Corporation.
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms and conditions of the GNU General Public License,
8  * version 2, as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  */
15 
16 #ifndef __IA_CSS_FRAME_COMM_H__
17 #define __IA_CSS_FRAME_COMM_H__
18 
19 #include "type_support.h"
20 #include "platform_support.h"
21 #include "runtime/bufq/interface/ia_css_bufq_comm.h"
22 #include <system_local.h>	 /* ia_css_ptr */
23 
24 /*
25  * These structs are derived from structs defined in ia_css_types.h
26  * (just take out the "_sp" from the struct name to get the "original")
27  * All the fields that are not needed by the SP are removed.
28  */
29 struct ia_css_frame_sp_plane {
30 	unsigned int offset;	/* offset in bytes to start of frame data */
31 	/* offset is wrt data in sh_css_sp_sp_frame */
32 };
33 
34 struct ia_css_frame_sp_binary_plane {
35 	unsigned int size;
36 	struct ia_css_frame_sp_plane data;
37 };
38 
39 struct ia_css_frame_sp_yuv_planes {
40 	struct ia_css_frame_sp_plane y;
41 	struct ia_css_frame_sp_plane u;
42 	struct ia_css_frame_sp_plane v;
43 };
44 
45 struct ia_css_frame_sp_nv_planes {
46 	struct ia_css_frame_sp_plane y;
47 	struct ia_css_frame_sp_plane uv;
48 };
49 
50 struct ia_css_frame_sp_rgb_planes {
51 	struct ia_css_frame_sp_plane r;
52 	struct ia_css_frame_sp_plane g;
53 	struct ia_css_frame_sp_plane b;
54 };
55 
56 struct ia_css_frame_sp_plane6 {
57 	struct ia_css_frame_sp_plane r;
58 	struct ia_css_frame_sp_plane r_at_b;
59 	struct ia_css_frame_sp_plane gr;
60 	struct ia_css_frame_sp_plane gb;
61 	struct ia_css_frame_sp_plane b;
62 	struct ia_css_frame_sp_plane b_at_r;
63 };
64 
65 struct ia_css_sp_resolution {
66 	u16 width;		/* width of valid data in pixels */
67 	u16 height;	/* Height of valid data in lines */
68 };
69 
70 /*
71  * Frame info struct. This describes the contents of an image frame buffer.
72  */
73 struct ia_css_frame_sp_info {
74 	struct ia_css_sp_resolution res;
75 	u16 padded_width;		/* stride of line in memory
76 					(in pixels) */
77 	unsigned char format;		/* format of the frame data */
78 	unsigned char raw_bit_depth;	/* number of valid bits per pixel,
79 					only valid for RAW bayer frames */
80 	unsigned char raw_bayer_order;	/* bayer order, only valid
81 					for RAW bayer frames */
82 	unsigned char padding[3];	/* Extend to 32 bit multiple */
83 };
84 
85 struct ia_css_buffer_sp {
86 	union {
87 		ia_css_ptr xmem_addr;
88 		enum sh_css_queue_id queue_id;
89 	} buf_src;
90 	enum ia_css_buffer_type buf_type;
91 };
92 
93 struct ia_css_frame_sp {
94 	struct ia_css_frame_sp_info info;
95 	struct ia_css_buffer_sp buf_attr;
96 	union {
97 		struct ia_css_frame_sp_plane raw;
98 		struct ia_css_frame_sp_plane rgb;
99 		struct ia_css_frame_sp_rgb_planes planar_rgb;
100 		struct ia_css_frame_sp_plane yuyv;
101 		struct ia_css_frame_sp_yuv_planes yuv;
102 		struct ia_css_frame_sp_nv_planes nv;
103 		struct ia_css_frame_sp_plane6 plane6;
104 		struct ia_css_frame_sp_binary_plane binary;
105 	} planes;
106 };
107 
108 void ia_css_frame_info_to_frame_sp_info(
109     struct ia_css_frame_sp_info *sp_info,
110     const struct ia_css_frame_info *info);
111 
112 void ia_css_resolution_to_sp_resolution(
113     struct ia_css_sp_resolution *sp_info,
114     const struct ia_css_resolution *info);
115 
116 #endif /*__IA_CSS_FRAME_COMM_H__*/
117