1 /*
2  * Support for Intel Camera Imaging ISP subsystem.
3  * Copyright (c) 2015, Intel Corporation.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  */
14 
15 #ifndef __IA_CSS_FIRMWARE_H
16 #define __IA_CSS_FIRMWARE_H
17 
18 /* @file
19  * This file contains firmware loading/unloading support functionality
20  */
21 
22 #include "ia_css_err.h"
23 #include "ia_css_env.h"
24 
25 /* CSS firmware package structure.
26  */
27 struct ia_css_fw {
28 	void	    *data;  /** pointer to the firmware data */
29 	unsigned int bytes; /** length in bytes of firmware data */
30 };
31 
32 /* @brief Loads the firmware
33  * @param[in]	env		Environment, provides functions to access the
34  *				environment in which the CSS code runs. This is
35  *				used for host side memory access and message
36  *				printing.
37  * @param[in]	fw		Firmware package containing the firmware for all
38  *				predefined ISP binaries.
39  * @return			Returns -EINVAL in case of any
40  *				errors and 0 otherwise.
41  *
42  * This function interprets the firmware package. All
43  * contents of this firmware package are copied into local data structures, so
44  * the fw pointer could be freed after this function completes.
45  *
46  * Rationale for this function is that it can be called before ia_css_init, and thus
47  * speeds up ia_css_init (ia_css_init is called each time a stream is created but the
48  * firmware only needs to be loaded once).
49  */
50 int
51 ia_css_load_firmware(struct device *dev, const struct ia_css_env *env,
52 		     const struct ia_css_fw  *fw);
53 
54 /* @brief Unloads the firmware
55  * @return	None
56  *
57  * This function unloads the firmware loaded by ia_css_load_firmware.
58  * It is pointless to call this function if no firmware is loaded,
59  * but it won't harm. Use this to deallocate all memory associated with the firmware.
60  */
61 void
62 ia_css_unload_firmware(void);
63 
64 #endif /* __IA_CSS_FIRMWARE_H */
65