1  /* SPDX-License-Identifier: GPL-2.0 */
2  /*
3   * Support for Medifield PNW Camera Imaging ISP subsystem.
4   *
5   * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
6   *
7   * This program is free software; you can redistribute it and/or
8   * modify it under the terms of the GNU General Public License version
9   * 2 as published by the Free Software Foundation.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   *
17   */
18  #ifndef __ATOMISP_CSI2_H__
19  #define __ATOMISP_CSI2_H__
20  
21  #include <linux/gpio/consumer.h>
22  #include <linux/property.h>
23  
24  #include <media/v4l2-subdev.h>
25  #include <media/v4l2-ctrls.h>
26  
27  #include "../../include/linux/atomisp.h"
28  
29  #define CSI2_PAD_SINK		0
30  #define CSI2_PAD_SOURCE		1
31  #define CSI2_PADS_NUM		2
32  
33  #define CSI2_MAX_ACPI_GPIOS	2u
34  
35  struct acpi_device;
36  struct v4l2_device;
37  
38  struct atomisp_device;
39  struct atomisp_sub_device;
40  
41  struct atomisp_csi2_acpi_gpio_map {
42  	struct acpi_gpio_params params[CSI2_MAX_ACPI_GPIOS];
43  	struct acpi_gpio_mapping mapping[CSI2_MAX_ACPI_GPIOS + 1];
44  };
45  
46  struct atomisp_csi2_acpi_gpio_parsing_data {
47  	struct acpi_device *adev;
48  	struct atomisp_csi2_acpi_gpio_map *map;
49  	u32 settings[CSI2_MAX_ACPI_GPIOS];
50  	unsigned int settings_count;
51  	unsigned int res_count;
52  	unsigned int map_count;
53  };
54  
55  struct atomisp_mipi_csi2_device {
56  	struct v4l2_subdev subdev;
57  	struct media_pad pads[CSI2_PADS_NUM];
58  	struct v4l2_mbus_framefmt formats[CSI2_PADS_NUM];
59  
60  	struct v4l2_ctrl_handler ctrls;
61  	struct atomisp_device *isp;
62  };
63  
64  int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd,
65  			  struct v4l2_subdev_state *sd_state,
66  			  unsigned int which, uint16_t pad,
67  			  struct v4l2_mbus_framefmt *ffmt);
68  int atomisp_mipi_csi2_init(struct atomisp_device *isp);
69  void atomisp_mipi_csi2_cleanup(struct atomisp_device *isp);
70  void atomisp_mipi_csi2_unregister_entities(
71      struct atomisp_mipi_csi2_device *csi2);
72  int atomisp_mipi_csi2_register_entities(struct atomisp_mipi_csi2_device *csi2,
73  					struct v4l2_device *vdev);
74  int atomisp_csi2_bridge_init(struct atomisp_device *isp);
75  int atomisp_csi2_bridge_parse_firmware(struct atomisp_device *isp);
76  
77  void atomisp_csi2_configure(struct atomisp_sub_device *asd);
78  
79  #endif /* __ATOMISP_CSI2_H__ */
80