Commit 0e75c07d authored by Andrey Filippov's avatar Andrey Filippov

merged with master

parents 17de2ffe f8137eab
......@@ -96,28 +96,19 @@ static int bitstream_loaded(u32 *ptr)
return 0;
}
static void elphel_defer_load(struct device *dev)
static int elphel_check_load(struct device *dev)
{
bool check_flag = true;
int ret = 0;
u32 *ctrl_ptr = ioremap_nocache(BITSTREAM_CTRL_ADDR, 4);
dev_info(dev, "AHCI driver loading is deferred. Load bitstream and write 1 into "
"/sys/devices/soc0/amba@0/80000000.elphel-ahci/load_module to continue\n");
while (check_flag) {
if (load_driver) {
if (bitstream_loaded(ctrl_ptr)) {
check_flag = false;
} else {
if (!bitstream_loaded(ctrl_ptr)) {
ret = -1;
dev_err(dev, "FPGA bitstream is not loaded or bitstream "
"does not contain AHCI controller\n");
load_driver = false;
}
} else {
msleep(1000);
}
"does not contain AHCI controller. Remove driver, load bitstream and try again\n");
}
load_driver = false;
iounmap(ctrl_ptr);
return ret;
}
static irqreturn_t elphel_irq_handler(int irq, void * dev_instance)
......@@ -274,12 +265,16 @@ static int elphel_drv_probe(struct platform_device *pdev)
const struct of_device_id *match;
struct ata_host *host;
ret = elphel_check_load(dev);
if (ret < 0) {
return ret;
}
if (&dev->kobj) {
ret = sysfs_create_group(&dev->kobj, &dev_attr_root_group);
if (ret < 0)
return ret;
}
elphel_defer_load(dev);
dev_info(&pdev->dev, "probing Elphel AHCI driver");
......
......@@ -433,6 +433,27 @@ int store_meta(int sensor_port) { //called from IRQ service - put current metada
if (aexif_wp[sensor_port] > MAX_EXIF_FRAMES) aexif_wp[sensor_port] = 1;
return meta_index;
}
/**
* @brief Go through mapping table and invalidate all tags that will be updated
* @param curr_table current mapping table
* @param curr_num the number of entries in current table
* @param new_table new mapping table of just a part of it
* @param new_num the number of entries in new table
*/
static void tags_invalidate(struct exif_dir_table_t *curr_table, int curr_num,
struct exif_dir_table_t *new_table, int new_num)
{
int i, j;
for (i = 0; i < curr_num; i++) {
for (j = 0; j < new_num; j++) {
if (curr_table[i].ltag == new_table[j].ltag) {
memset(&curr_table[i], 0, sizeof(struct exif_dir_table_t));
}
}
}
}
//!++++++++++++++++++++++++++++++++++++ open() ++++++++++++++++++++++++++++++++++++++++++++++++++++++
......@@ -600,7 +621,8 @@ ssize_t exif_write (struct file * file, const char * buf, size_t count, loff
int sensor_port;
// int thissize=minor_file_size(p);
int maxsize=minor_max_size(p);
char * cp;
int fields_num;
char * cp, *new_table;
char tmp[MAX_EXIF_SIZE]; //! Or is it possible to disable IRQ while copy_from_user()?
unsigned long flags;
int disabled_err=0;
......@@ -620,8 +642,19 @@ ssize_t exif_write (struct file * file, const char * buf, size_t count, loff
case DEV393_MINOR(DEV393_EXIF_METADIR):
exif_invalidate();
cp= (char *) &dir_table;
if (copy_from_user(&cp[*off], buf, count)) return -EFAULT;
new_table = kmalloc(MAX_EXIF_FIELDS * sizeof(struct exif_dir_table_t), GFP_KERNEL);
if (!new_table) {
return -ENOMEM;
}
if (copy_from_user(new_table, buf, count)) {
kfree(new_table);
return -EFAULT;
}
fields_num = exif_fields;
exif_fields=(*off+count)/sizeof(struct exif_dir_table_t);
tags_invalidate(dir_table, fields_num, (struct exif_dir_table_t *)new_table, exif_fields);
memcpy(&cp[*off], new_table, count);
kfree(new_table);
break;
case DEV393_MINOR(DEV393_EXIF_TIME): //write date/time first, then - midnight seconds
cp= (char *) &exif_time;
......@@ -733,7 +766,6 @@ ssize_t exif_read (struct file * file, char * buf, size_t count, loff_t *of
/* This code is copied from exif_read, consider replacing it with this function invocation */
size_t exif_get_data(int sensor_port, unsigned short meta_index, void *buff, size_t buff_sz)
{
size_t ret = 0;
size_t count = exif_template_size;
loff_t off;
int start_p, page_p, i;
......
......@@ -198,7 +198,9 @@ const unsigned long param_depend_tab[]=
ONCHANGE_MEMSENSOR | ONCHANGE_MEMCOMPRESSOR | ONCHANGE_COMPMODE | ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART | ONCHANGE_SENSORIN,
P_BIN_VERT, ONCHANGE_WINDOW | ONCHANGE_EXPOSURE | ONCHANGE_HIST | ONCHANGE_AEXP | ONCHANGE_FOCUSMODE | ONCHANGE_LIMITFPS | ONCHANGE_HIST | \
ONCHANGE_MEMSENSOR | ONCHANGE_MEMCOMPRESSOR | ONCHANGE_COMPMODE | ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART | ONCHANGE_SENSORIN ,
P_COLOR, ONCHANGE_COMPMODE | ONCHANGE_LIMITFPS | ONCHANGE_MEMCOMPRESSOR,
//Oleg 20161014: trying to restart the compressor: + ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART
P_COLOR, ONCHANGE_COMPMODE | ONCHANGE_LIMITFPS | ONCHANGE_MEMCOMPRESSOR | ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART,
//P_COLOR, ONCHANGE_COMPMODE | ONCHANGE_LIMITFPS | ONCHANGE_MEMCOMPRESSOR,
// P_PF_HEIGHT, ONCHANGE_RECALCSEQ | ONCHANGE_SENSORIN | ONCHANGE_LIMITFPS | ONCHANGE_MEMSENSOR | ONCHANGE_MEMCOMPRESSOR | ONCHANGE_COMPMODE | ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART ,
P_PF_HEIGHT, ONCHANGE_RECALCSEQ | ONCHANGE_WINDOW | ONCHANGE_EXPOSURE | ONCHANGE_HIST | ONCHANGE_AEXP | ONCHANGE_FOCUSMODE | ONCHANGE_LIMITFPS | ONCHANGE_HIST | \
ONCHANGE_MEMSENSOR | ONCHANGE_MEMCOMPRESSOR | ONCHANGE_COMPMODE | ONCHANGE_COMPSTOP | ONCHANGE_COMPRESTART | ONCHANGE_SENSORIN ,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment