mirror of
https://github.com/sipeed/LicheeRV-Nano-Build.git
synced 2026-11-09 18:04:55 -06:00
Modify cif.c for NanoKVM
Notify kvm_mmf during resolution switching.
This commit is contained in:
@@ -35,6 +35,15 @@
|
||||
#include <base_cb.h>
|
||||
#include <cif_cb.h>
|
||||
|
||||
#include <linux/init.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
#define PROC_FILE_NAME "lt_int"
|
||||
|
||||
#define MIPI_IF
|
||||
#define DVP_IF
|
||||
#define BT601_IF
|
||||
@@ -55,6 +64,45 @@
|
||||
#define MIPI_RX_DEV_NAME "cvi-mipi-rx"
|
||||
#define MAX_CIF_PROC_BUF 32
|
||||
|
||||
static int data = 0;
|
||||
|
||||
static int my_proc_show(struct seq_file *m, void *v) {
|
||||
seq_printf(m, "%d\n", data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int my_proc_open(struct inode *inode, struct file *file) {
|
||||
return single_open(file, my_proc_show, NULL);
|
||||
}
|
||||
|
||||
static ssize_t my_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *f_pos) {
|
||||
char kbuf[16];
|
||||
int value;
|
||||
|
||||
if (count > sizeof(kbuf) - 1) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (copy_from_user(kbuf, buf, count)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
kbuf[count] = '\0';
|
||||
if (sscanf(kbuf, "%d", &value) != 1) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
data = value;
|
||||
return count;
|
||||
}
|
||||
static const struct proc_ops my_proc_fops = {
|
||||
.proc_open = my_proc_open,
|
||||
.proc_read = seq_read,
|
||||
.proc_lseek = seq_lseek,
|
||||
.proc_release = single_release,
|
||||
.proc_write = my_proc_write,
|
||||
};
|
||||
|
||||
enum {
|
||||
LANE_SKEW_CROSS_CLK,
|
||||
LANE_SKEW_CROSS_DATA_NEAR,
|
||||
@@ -64,6 +112,28 @@ enum {
|
||||
LANE_SKEW_NUM,
|
||||
};
|
||||
|
||||
struct btn_resource {
|
||||
int gpio;
|
||||
char *name;
|
||||
int code;
|
||||
};
|
||||
static struct btn_resource btn_info = {
|
||||
.gpio = 353,
|
||||
.name = "LT-INT",
|
||||
.code = 1,
|
||||
};
|
||||
|
||||
static irqreturn_t button_isr(int irq, void *dev)
|
||||
{
|
||||
printk("LT6911--:-- INT!!##\n");
|
||||
if(gpio_get_value(btn_info.gpio) == 0){
|
||||
data += 10;
|
||||
} else {
|
||||
data += 1;
|
||||
}
|
||||
return IRQ_HANDLED; //执行成功
|
||||
}
|
||||
|
||||
static int mclk0 = CAMPLL_FREQ_NONE;
|
||||
module_param(mclk0, int, 0644);
|
||||
MODULE_PARM_DESC(mclk0, "cam0 mclk");
|
||||
@@ -2035,7 +2105,7 @@ static inline int cif_set_crop_top(struct cvi_cif_dev *dev,
|
||||
|
||||
dev->link[crop->devno].crop_top = crop->crop_top;
|
||||
/* strip the top info line. */
|
||||
cif_crop_info_line(ctx, crop->crop_top, crop->update);
|
||||
cif_crop_info_line(ctx, crop->crop_top, crop->update);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2768,6 +2838,7 @@ static char irq_name[MAX_LINK_NUM][20] = {
|
||||
|
||||
static int _init_resource(struct platform_device *pdev)
|
||||
{
|
||||
int lt_irq;
|
||||
#if (DEVICE_FROM_DTS)
|
||||
struct resource *res = NULL;
|
||||
void *reg_base[6];
|
||||
@@ -2860,13 +2931,34 @@ static int _init_resource(struct platform_device *pdev)
|
||||
link->cif_ctx.mac_num = i;
|
||||
}
|
||||
|
||||
proc_create(PROC_FILE_NAME, 0666, NULL, &my_proc_fops);
|
||||
// LT6911 GPIO5 INT
|
||||
|
||||
// 1.申请GPIO资源
|
||||
// 2.申请中断资源,注册中断处理函数
|
||||
// 由GPIO编号求中断号
|
||||
lt_irq = gpio_to_irq(btn_info.gpio);
|
||||
gpio_request( btn_info.gpio,
|
||||
btn_info.name);
|
||||
request_irq ( lt_irq, //中断号
|
||||
button_isr, //注册的中断处理函数
|
||||
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
||||
btn_info.name, //中断名称
|
||||
&btn_info //将每个按键对应的硬件信息传递给中断处理函数
|
||||
);
|
||||
|
||||
/* reset pin */
|
||||
for (i = 0; i < MAX_LINK_NUM; ++i) {
|
||||
link = &dev->link[i];
|
||||
link->dev = &pdev->dev;
|
||||
link->mac_clk = RX_MAC_CLK_400M;
|
||||
link->snsr_rst_pin = of_get_named_gpio_flags(pdev->dev.of_node,
|
||||
"snsr-reset", i, &link->snsr_rst_pol);
|
||||
// link->snsr_rst_pin = of_get_named_gpio_flags(pdev->dev.of_node,
|
||||
// "snsr-reset", i, &link->snsr_rst_pol);
|
||||
if(i == 0)
|
||||
link->snsr_rst_pin = 361;
|
||||
else
|
||||
link->snsr_rst_pin = -2;
|
||||
// dev_info(&pdev->dev, "snsr_rst_pin%d\n", link->snsr_rst_pin);
|
||||
if (link->snsr_rst_pin < 0)
|
||||
break;
|
||||
|
||||
@@ -3353,10 +3445,16 @@ static int __init cvi_cif_init(void)
|
||||
|
||||
static void __exit cvi_cif_exit(void)
|
||||
{
|
||||
int lt_irq;
|
||||
platform_driver_unregister(&cvi_cif_pdrv);
|
||||
#if (!DEVICE_FROM_DTS)
|
||||
platform_device_unregister(&cvi_cif_pdev);
|
||||
#endif
|
||||
lt_irq = gpio_to_irq(btn_info.gpio);
|
||||
gpio_free(btn_info.gpio);
|
||||
free_irq(lt_irq, &btn_info);
|
||||
|
||||
remove_proc_entry(PROC_FILE_NAME, NULL);
|
||||
}
|
||||
|
||||
MODULE_DESCRIPTION("Cvitek Camera Interface Driver");
|
||||
|
||||
Reference in New Issue
Block a user