xref: /linux/drivers/staging/media/atomisp/pci/ia_css_metadata.h (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Intel Camera Imaging ISP subsystem.
4  * Copyright (c) 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_METADATA_H
17 #define __IA_CSS_METADATA_H
18 
19 /* @file
20  * This file contains structure for processing sensor metadata.
21  */
22 
23 #include <linux/build_bug.h>
24 
25 #include <type_support.h>
26 #include "ia_css_types.h"
27 #include "ia_css_stream_format.h"
28 
29 /* Metadata configuration. This data structure contains necessary info
30  *  to process sensor metadata.
31  */
32 struct ia_css_metadata_config {
33 	enum atomisp_input_format data_type; /** Data type of CSI-2 embedded
34 			data. The default value is ATOMISP_INPUT_FORMAT_EMBEDDED. For
35 			certain sensors, user can choose non-default data type for embedded
36 			data. */
37 	struct ia_css_resolution  resolution; /** Resolution */
38 };
39 
40 struct ia_css_metadata_info {
41 	struct ia_css_resolution resolution; /** Resolution */
42 	u32                 stride;     /** Stride in bytes */
43 	u32                 size;       /** Total size in bytes */
44 };
45 
46 struct ia_css_metadata {
47 	struct ia_css_metadata_info info;    /** Layout info */
48 	ia_css_ptr		    address; /** CSS virtual address */
49 	u32		    exp_id;
50 	/** Exposure ID, see ia_css_event_public.h for more detail */
51 };
52 
53 #define SIZE_OF_IA_CSS_METADATA_STRUCT sizeof(struct ia_css_metadata)
54 
55 static_assert(sizeof(struct ia_css_metadata) == SIZE_OF_IA_CSS_METADATA_STRUCT);
56 
57 /* @brief Allocate a metadata buffer.
58  * @param[in]   metadata_info Metadata info struct, contains details on metadata buffers.
59  * @return      Pointer of metadata buffer or NULL (if error)
60  *
61  * This function allocates a metadata buffer according to the properties
62  * specified in the metadata_info struct.
63  */
64 struct ia_css_metadata *
65 ia_css_metadata_allocate(const struct ia_css_metadata_info *metadata_info);
66 
67 /* @brief Free a metadata buffer.
68  *
69  * @param[in]	metadata	Pointer of metadata buffer.
70  * @return	None
71  *
72  * This function frees a metadata buffer.
73  */
74 void
75 ia_css_metadata_free(struct ia_css_metadata *metadata);
76 
77 #endif /* __IA_CSS_METADATA_H */
78