• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) Rockchip Electronics Co., Ltd. */
3 #include <linux/clk.h>
4 #include <linux/proc_fs.h>
5 #include <linux/sem.h>
6 #include <linux/seq_file.h>
7 #include <media/v4l2-common.h>
8 
9 #include "dev.h"
10 #include "procfs.h"
11 #include "regs.h"
12 #include "version.h"
13 
14 #ifdef CONFIG_PROC_FS
ispp_show(struct seq_file * p,void * v)15 static int ispp_show(struct seq_file *p, void *v)
16 {
17 	struct rkispp_device *dev = p->private;
18 	enum rkispp_state state = dev->ispp_sdev.state;
19 	struct rkispp_stream *stream;
20 	u32 val;
21 
22 	seq_printf(p, "%-10s Version:v%02x.%02x.%02x\n",
23 		   dev->name,
24 		   RKISPP_DRIVER_VERSION >> 16,
25 		   (RKISPP_DRIVER_VERSION & 0xff00) >> 8,
26 		   RKISPP_DRIVER_VERSION & 0x00ff);
27 	for (val = 0; val < dev->hw_dev->clks_num; val++) {
28 		seq_printf(p, "%-10s %ld\n",
29 			   dev->hw_dev->match_data->clks[val],
30 			   clk_get_rate(dev->hw_dev->clks[val]));
31 	}
32 	if (state != ISPP_START)
33 		return 0;
34 
35 	seq_printf(p, "%-10s Cnt:%d ErrCnt:%d\n",
36 		   "Interrupt",
37 		   dev->isr_cnt,
38 		   dev->isr_err_cnt);
39 	seq_printf(p, "%-10s rkisp%d Format:%s%s Size:%dx%d (frame:%d rate:%dms delay:%dms)\n",
40 		   "Input",
41 		   dev->dev_id,
42 		   (dev->isp_mode & FMT_FBC) ? "FBC" : "YUV",
43 		   (dev->isp_mode & FMT_YUV422) ? "422" : "420",
44 		   dev->ispp_sdev.out_fmt.width,
45 		   dev->ispp_sdev.out_fmt.height,
46 		   dev->stream_vdev.dbg.id,
47 		   dev->stream_vdev.dbg.interval / 1000 / 1000,
48 		   dev->stream_vdev.dbg.delay / 1000 / 1000);
49 	for (val = STREAM_MB; val <= STREAM_S2; val++) {
50 		stream = &dev->stream_vdev.stream[val];
51 		if (!stream->streaming)
52 			continue;
53 		seq_printf(p, "%-10s %s Format:%c%c%c%c Size:%dx%d (frame:%d rate:%dms delay:%dms frameloss:%d)\n",
54 			   "Output",
55 			   stream->vnode.vdev.name,
56 			   stream->out_fmt.pixelformat,
57 			   stream->out_fmt.pixelformat >> 8,
58 			   stream->out_fmt.pixelformat >> 16,
59 			   stream->out_fmt.pixelformat >> 24,
60 			   stream->out_fmt.width,
61 			   stream->out_fmt.height,
62 			   stream->dbg.id,
63 			   stream->dbg.interval / 1000 / 1000,
64 			   stream->dbg.delay / 1000 / 1000,
65 			   stream->dbg.frameloss);
66 	}
67 
68 	val = rkispp_read(dev, RKISPP_TNR_CORE_CTRL);
69 	seq_printf(p, "%-10s %s(0x%x) (mode: %s) (global gain: %s) (frame:%d time:%dms %s) CNT:0x%x STATE:0x%x\n",
70 		   "TNR",
71 		   (val & 1) ? "ON" : "OFF", val,
72 		   (val & SW_TNR_MODE) ? "3to1" : "2to1",
73 		   (val & SW_TNR_GLB_GAIN_EN) ? "enable" : "disable",
74 		   dev->stream_vdev.tnr.dbg.id,
75 		   dev->stream_vdev.tnr.dbg.interval / 1000 / 1000,
76 		   dev->stream_vdev.tnr.is_end ? "idle" : "working",
77 		   rkispp_read(dev, RKISPP_TNR_TILE_CNT),
78 		   rkispp_read(dev, RKISPP_TNR_STATE));
79 	val = rkispp_read(dev, RKISPP_NR_UVNR_CTRL_PARA);
80 	seq_printf(p, "%-10s %s(0x%x) (external gain: %s) (frame:%d time:%dms %s) 0x%x:0x%x 0x%x:0x%x\n",
81 		   "NR",
82 		   (val & 1) ? "ON" : "OFF", val,
83 		   (val & SW_NR_GAIN_BYPASS) ? "disable" : "enable",
84 		   dev->stream_vdev.nr.dbg.id,
85 		   dev->stream_vdev.nr.dbg.interval / 1000 / 1000,
86 		   dev->stream_vdev.nr.is_end ? "idle" : "working",
87 		   RKISPP_NR_BLOCK_CNT, rkispp_read(dev, RKISPP_NR_BLOCK_CNT),
88 		   RKISPP_NR_BUFFER_READY, rkispp_read(dev, RKISPP_NR_BUFFER_READY));
89 	val = rkispp_read(dev, RKISPP_SHARP_CORE_CTRL);
90 	seq_printf(p, "%-10s %s(0x%x) (YNR input filter: %s) (local ratio: %s) 0x%x:0x%x\n",
91 		   "SHARP",
92 		   (val & 1) ? "ON" : "OFF", val,
93 		   (val & SW_SHP_YIN_FLT_EN) ? "ON" : "OFF",
94 		   (val & SW_SHP_ALPHA_ADP_EN) ? "ON" : "OFF",
95 		   RKISPP_SHARP_TILE_IDX, rkispp_read(dev, RKISPP_SHARP_TILE_IDX));
96 	val = rkispp_read(dev, RKISPP_FEC_CORE_CTRL);
97 	seq_printf(p, "%-10s %s(0x%x) (frame:%d time:%dms %s) 0x%x:0x%x\n",
98 		   "FEC",
99 		   (val & 1) ? "ON" : "OFF", val,
100 		   dev->stream_vdev.fec.dbg.id,
101 		   dev->stream_vdev.fec.dbg.interval / 1000 / 1000,
102 		   dev->stream_vdev.fec.is_end ? "idle" : "working",
103 		   RKISPP_FEC_DMA_STATUS, rkispp_read(dev, RKISPP_FEC_DMA_STATUS));
104 	val = rkispp_read(dev, RKISPP_ORB_CORE_CTRL);
105 	seq_printf(p, "%-10s %s(0x%x)\n",
106 		   "ORB",
107 		   (val & 1) ? "ON" : "OFF", val);
108 	seq_printf(p, "%-10s %s Cnt:%d\n",
109 		   "Monitor",
110 		   dev->stream_vdev.monitor.is_en ? "ON" : "OFF",
111 		   dev->stream_vdev.monitor.retry);
112 	return 0;
113 }
114 
ispp_open(struct inode * inode,struct file * file)115 static int ispp_open(struct inode *inode, struct file *file)
116 {
117 	struct rkispp_device *data = PDE_DATA(inode);
118 
119 	return single_open(file, ispp_show, data);
120 }
121 
122 static const struct proc_ops ops = {
123 	.proc_open		= ispp_open,
124 	.proc_read		= seq_read,
125 	.proc_lseek		= seq_lseek,
126 	.proc_release		= single_release,
127 };
128 
rkispp_proc_init(struct rkispp_device * dev)129 int rkispp_proc_init(struct rkispp_device *dev)
130 {
131 	dev->procfs = proc_create_data(dev->name, 0, NULL, &ops, dev);
132 	if (!dev->procfs)
133 		return -EINVAL;
134 	return 0;
135 }
136 
rkispp_proc_cleanup(struct rkispp_device * dev)137 void rkispp_proc_cleanup(struct rkispp_device *dev)
138 {
139 	if (dev->procfs)
140 		remove_proc_entry(dev->name, NULL);
141 	dev->procfs = NULL;
142 }
143 #endif /* CONFIG_PROC_FS */
144