blob: acf945e0456125e9f81ed74a349003f7a51d5bb3 [file] [log] [blame]
Pratap Nirujogi6e759912018-01-17 17:51:17 +05301/* Copyright (c) 2012-2016, 2018, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13
14
15#ifndef MSM_JPEG_SYNC_H
16#define MSM_JPEG_SYNC_H
17
18#include <linux/fs.h>
19#include <linux/list.h>
20#include <linux/cdev.h>
21#include <linux/platform_device.h>
22#include <media/v4l2-device.h>
23#include <media/v4l2-subdev.h>
24#include "msm_camera_io_util.h"
25#include "msm_jpeg_hw.h"
26#include "cam_smmu_api.h"
27#include "cam_soc_api.h"
28
29#define JPEG_8974_V1 0x10000000
30#define JPEG_8974_V2 0x10010000
31#define JPEG_8994 0x10020000
32#define JPEG_CLK_MAX 16
33#define JPEG_REGULATOR_MAX 3
34
35enum msm_jpeg_state {
36 MSM_JPEG_INIT,
37 MSM_JPEG_RESET,
38 MSM_JPEG_EXECUTING,
39 MSM_JPEG_STOPPED,
40 MSM_JPEG_IDLE
41};
42
43enum msm_jpeg_core_type {
44 MSM_JPEG_CORE_CODEC,
45 MSM_JPEG_CORE_DMA
46};
47
48struct msm_jpeg_q {
49 char const *name;
50 struct list_head q;
51 spinlock_t lck;
52 wait_queue_head_t wait;
53 int unblck;
54};
55
56struct msm_jpeg_q_entry {
57 struct list_head list;
58 void *data;
59};
60
61struct msm_jpeg_device {
62 struct platform_device *pdev;
63 struct resource *jpeg_irq_res;
64 void *base;
65 void *vbif_base;
66 struct clk **jpeg_clk;
67 struct msm_cam_clk_info *jpeg_clk_info;
68 size_t num_clk;
69 int num_reg;
70 struct msm_cam_regulator *jpeg_vdd;
71 uint32_t hw_version;
72
73 struct device *device;
74 struct cdev cdev;
75 struct mutex lock;
76 char open_count;
77 uint8_t op_mode;
78
79 /* Flag to store the jpeg bus vote state
80 */
81 int jpeg_bus_vote;
82
83 /* event queue including frame done & err indications
84 */
85 struct msm_jpeg_q evt_q;
86
87 /* output return queue
88 */
89 struct msm_jpeg_q output_rtn_q;
90
91 /* output buf queue
92 */
93 struct msm_jpeg_q output_buf_q;
94
95 /* input return queue
96 */
97 struct msm_jpeg_q input_rtn_q;
98
99 /* input buf queue
100 */
101 struct msm_jpeg_q input_buf_q;
102
103 struct v4l2_subdev subdev;
104
105 struct class *msm_jpeg_class;
106
107 dev_t msm_jpeg_devno;
108
109 /*iommu domain and context*/
110 int idx;
111 int iommu_hdl;
112 int decode_flag;
113 void *jpeg_vbif;
114 int release_buf;
115 struct msm_jpeg_hw_pingpong fe_pingpong_buf;
116 struct msm_jpeg_hw_pingpong we_pingpong_buf;
117 int we_pingpong_index;
118 int reset_done_ack;
119 spinlock_t reset_lock;
120 wait_queue_head_t reset_wait;
121 uint32_t res_size;
122 enum msm_jpeg_state state;
123 enum msm_jpeg_core_type core_type;
124 enum cam_bus_client bus_client;
125};
126
127int __msm_jpeg_open(struct msm_jpeg_device *pgmn_dev);
128int __msm_jpeg_release(struct msm_jpeg_device *pgmn_dev);
129
130long __msm_jpeg_ioctl(struct msm_jpeg_device *pgmn_dev,
131 unsigned int cmd, unsigned long arg);
132
133#ifdef CONFIG_COMPAT
134long __msm_jpeg_compat_ioctl(struct msm_jpeg_device *pgmn_dev,
135 unsigned int cmd, unsigned long arg);
136#endif
137
138int __msm_jpeg_init(struct msm_jpeg_device *pgmn_dev);
139int __msm_jpeg_exit(struct msm_jpeg_device *pgmn_dev);
140
141#endif /* MSM_JPEG_SYNC_H */