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_H__
17  #define __IA_CSS_FRAME_H__
18  
19  /* ISP2401 */
20  #include <ia_css_types.h>
21  
22  #include <ia_css_frame_format.h>
23  #include <ia_css_frame_public.h>
24  #include "dma.h"
25  
26  /*********************************************************************
27  ****	Frame INFO APIs
28  **********************************************************************/
29  /* @brief Sets the given width and alignment to the frame info
30   *
31   * @param
32   * @param[in]	info        The info to which parameters would set
33   * @param[in]	width       The width to be set to info
34   * @param[in]	aligned     The aligned to be set to info
35   * @return
36   */
37  void ia_css_frame_info_set_width(struct ia_css_frame_info *info,
38  				 unsigned int width,
39  				 unsigned int min_padded_width);
40  
41  /* @brief Sets the given format to the frame info
42   *
43   * @param
44   * @param[in]	info        The info to which parameters would set
45   * @param[in]	format      The format to be set to info
46   * @return
47   */
48  void ia_css_frame_info_set_format(struct ia_css_frame_info *info,
49  				  enum ia_css_frame_format format);
50  
51  /* @brief Sets the frame info with the given parameters
52   *
53   * @param
54   * @param[in]	info        The info to which parameters would set
55   * @param[in]	width       The width to be set to info
56   * @param[in]	height      The height to be set to info
57   * @param[in]	format      The format to be set to info
58   * @param[in]	aligned     The aligned to be set to info
59   * @return
60   */
61  void ia_css_frame_info_init(struct ia_css_frame_info *info,
62  			    unsigned int width,
63  			    unsigned int height,
64  			    enum ia_css_frame_format format,
65  			    unsigned int aligned);
66  
67  /* @brief Checks whether 2 frame infos has the same resolution
68   *
69   * @param
70   * @param[in]	frame_a         The first frame to be compared
71   * @param[in]	frame_b         The second frame to be compared
72   * @return      Returns true if the frames are equal
73   */
74  bool ia_css_frame_info_is_same_resolution(
75      const struct ia_css_frame_info *info_a,
76      const struct ia_css_frame_info *info_b);
77  
78  /* @brief Check the frame info is valid
79   *
80   * @param
81   * @param[in]	info       The frame attributes to be initialized
82   * @return	The error code.
83   */
84  int ia_css_frame_check_info(const struct ia_css_frame_info *info);
85  
86  /*********************************************************************
87  ****	Frame APIs
88  **********************************************************************/
89  
90  /* @brief Initialize the plane depending on the frame type
91   *
92   * @param
93   * @param[in]	frame           The frame attributes to be initialized
94   * @return	The error code.
95   */
96  int ia_css_frame_init_planes(struct ia_css_frame *frame);
97  
98  /* @brief Free an array of frames
99   *
100   * @param
101   * @param[in]	num_frames      The number of frames to be freed in the array
102   * @param[in]   **frames_array  The array of frames to be removed
103   * @return
104   */
105  void ia_css_frame_free_multiple(unsigned int num_frames,
106  				struct ia_css_frame **frames_array);
107  
108  /* @brief Allocate a CSS frame structure of given size in bytes..
109   *
110   * @param	frame	The allocated frame.
111   * @param[in]	size_bytes	The frame size in bytes.
112   * @return	The error code.
113   *
114   * Allocate a frame using the given size in bytes.
115   * The frame structure is partially null initialized.
116   */
117  int ia_css_frame_allocate_with_buffer_size(struct ia_css_frame **frame,
118  					   const unsigned int size_bytes);
119  
120  /* @brief Check whether 2 frames are same type
121   *
122   * @param
123   * @param[in]	frame_a         The first frame to be compared
124   * @param[in]	frame_b         The second frame to be compared
125   * @return      Returns true if the frames are equal
126   */
127  bool ia_css_frame_is_same_type(
128      const struct ia_css_frame *frame_a,
129      const struct ia_css_frame *frame_b);
130  
131  /* @brief Configure a dma port from frame info
132   *
133   * @param
134   * @param[in]	config         The DAM port configuration
135   * @param[in]	info           The frame info
136   * @return
137   */
138  int ia_css_dma_configure_from_info(struct dma_port_config *config,
139  				   const struct ia_css_frame_info *info);
140  
141  #endif /* __IA_CSS_FRAME_H__ */
142