Repository navigation
Expand file tree
/
Copy pathfthd_drv.h
More file actions
133 lines (111 loc) · 2.91 KB
/
Copy pathfthd_drv.h
File metadata and controls
133 lines (111 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* SPDX-License-Identifier: GPL-2.0-only
*
* FacetimeHD camera driver
*
* Copyright (C) 2014 Patrik Jakobsson (patrik.r.jakobsson@gmail.com)
*
*/
#ifndef _FTHD_DRV_H
#define _FTHD_DRV_H
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/version.h>
#include <media/videobuf2-dma-sg.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ctrls.h>
#include "fthd_reg.h"
#include "fthd_ringbuf.h"
#include "fthd_buffer.h"
#include "fthd_v4l2.h"
#define FTHD_PCI_S2_IO 0
#define FTHD_PCI_S2_MEM 2
#define FTHD_PCI_ISP_IO 4
#define FTHD_BUFFERS 8
#define FTHD_FRAME_RATE_SCALE 256U
#define FTHD_FRAME_RATE_MIN (2 * FTHD_FRAME_RATE_SCALE)
#define FTHD_FRAME_RATE_MAX (30 * FTHD_FRAME_RATE_SCALE)
enum FW_CHAN_TYPE {
FW_CHAN_TYPE_OUT=0,
FW_CHAN_TYPE_IN=1,
FW_CHAN_TYPE_UNI_IN=2,
};
struct fw_channel {
u32 offset;
u32 size;
u32 source;
u32 type;
struct fthd_ringbuf ringbuf;
spinlock_t lock;
/* waitqueue for signaling completion */
wait_queue_head_t wq;
char *name;
};
struct fthd_private {
struct pci_dev *pdev;
unsigned int dma_mask;
struct v4l2_device v4l2_dev;
struct video_device *videodev;
struct mutex ioctl_lock;
atomic_t users;
/* lock for synchronizing with irq/workqueue */
spinlock_t io_lock;
/* Mapped PCI resources */
void __iomem *s2_io;
u32 s2_io_len;
void __iomem *s2_mem;
u32 s2_mem_len;
void __iomem *isp_io;
u32 isp_io_len;
struct work_struct irq_work;
/* Hardware info */
u32 core_clk;
u32 ddr_model;
u32 ddr_speed;
u32 vdl_step_size;
u32 ddr_phy_regs[DDR_PHY_NUM_REG];
/* Root resource for memory management */
struct resource *mem;
/* Resource for managing IO mmu slots */
struct resource *iommu;
/* ISP memory objects */
struct isp_mem_obj *firmware;
struct isp_mem_obj *set_file;
struct isp_mem_obj *ipc_queue;
struct isp_mem_obj *heap;
/* Firmware channels */
int num_channels;
struct fw_channel **channels;
struct fw_channel *channel_terminal;
struct fw_channel *channel_io;
struct fw_channel *channel_debug;
struct fw_channel *channel_buf_h2t;
struct fw_channel *channel_buf_t2h;
struct fw_channel *channel_shared_malloc;
struct fw_channel *channel_io_t2h;
/* camera config */
int sensor_count;
int sensor_id0;
int sensor_id1;
/* Native sensor resolution, read from the firmware's per-channel camera
* config. MacBookPro sensors report 1280x720; the 12-inch MacBook
* (MacBook8,1, sensor 1675) reports 848x588. 0 until detected. */
unsigned int sensor_width;
unsigned int sensor_height;
struct fthd_fmt fmt;
struct vb2_queue vb2_queue;
struct mutex vb2_queue_lock;
struct list_head buffer_queue;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,8,0)
struct vb2_alloc_ctx *alloc_ctx;
#endif
struct h2t_buf_ctx h2t_bufs[FTHD_BUFFERS];
struct v4l2_ctrl_handler v4l2_ctrl_handler;
u32 frame_rate; /* 1/256 fps */
int exposure_auto_priority;
unsigned int sequence;
struct dentry *debugfs;
};
#endif