diff --git a/src/drivers/ata/ahci_elphel.c b/src/drivers/ata/ahci_elphel.c index d01ca83df5f855c15b46405924f0c7be9d604a84..8cb8e302cd7a596f8b6075b7125a1958f18bb127 100644 --- a/src/drivers/ata/ahci_elphel.c +++ b/src/drivers/ata/ahci_elphel.c @@ -27,17 +27,16 @@ #include #include #include -#include +#include +#include #include "ahci.h" #include "ahci_elphel.h" #include "../elphel/exif393.h" -#include "../elphel/exifa.h" #include "../elphel/jpeghead.h" +#include "../elphel/circbuf.h" #include "../elphel/x393_helpers.h" -#include - #define DRV_NAME "elphel-ahci" /* * FPGA bitstream control address and bit mask. These are used to check whether @@ -409,19 +408,6 @@ static void elphel_qc_prep(struct ata_queued_cmd *qc) AHCI_CMD_TBL_AR_SZ, DMA_TO_DEVICE); } - -/* this should be placed to system includes directory*/ -#define DRV_CMD_WRITE 0 -#define DRV_CMD_FINISH 1 -struct frame_data { - unsigned int sensor_port; - int cirbuf_ptr; - int jpeg_len; - int meta_index; - int cmd; -}; -/* end of system includes */ - /** Map buffer vectors to S/G list and return the number of vectors mapped */ static int map_vectors(struct elphel_ahci_priv *dpriv) { @@ -1071,7 +1057,7 @@ static ssize_t rawdev_write(struct device *dev, ///< } spin_unlock_irqrestore(&dpriv->flags_lock, irq_flags); - if (fdata.cmd == DRV_CMD_FINISH) { + if (fdata.cmd & DRV_CMD_FINISH) { if ((dpriv->flags & PROC_CMD) == 0 && proceed) { finish_rec(dpriv); } else { @@ -1088,9 +1074,11 @@ static ssize_t rawdev_write(struct device *dev, ///< chunks = dpriv->data_chunks[dpriv->tail_ptr]; buffs = &dpriv->fbuffs[dpriv->tail_ptr]; - dev_dbg(dev, "process frame from sensor port: %u\n", fdata.sensor_port); - rcvd = exif_get_data(fdata.sensor_port, fdata.meta_index, buffs->exif_buff.iov_base, buffs->exif_buff.iov_len); - chunks[CHUNK_EXIF].iov_len = rcvd; + dev_dbg(dev, "process frame from sensor port: %u, command = %d\n", fdata.sensor_port, fdata.cmd); + if (fdata.cmd & DRV_CMD_EXIF) { + rcvd = exif_get_data(fdata.sensor_port, fdata.meta_index, buffs->exif_buff.iov_base, buffs->exif_buff.iov_len); + chunks[CHUNK_EXIF].iov_len = rcvd; + } rcvd = jpeghead_get_data(fdata.sensor_port, buffs->jpheader_buff.iov_base, buffs->jpheader_buff.iov_len, 0); chunks[CHUNK_LEADER].iov_len = JPEG_MARKER_LEN; @@ -1329,16 +1317,16 @@ static ssize_t lba_current_write(struct device *dev, struct device_attribute *at } static DEVICE_ATTR(load_module, S_IWUSR | S_IWGRP, NULL, set_load_flag); -static DEVICE_ATTR(write, S_IWUSR | S_IWGRP, NULL, rawdev_write); -static DEVICE_ATTR(lba_start, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP, lba_start_read, lba_start_write); -static DEVICE_ATTR(lba_end, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP, lba_end_read, lba_end_write); -static DEVICE_ATTR(lba_current, S_IRUSR | S_IRGRP | S_IWUSR | S_IRGRP, lba_current_read, lba_current_write); +static DEVICE_ATTR(SYSFS_AHCI_FNAME_WRITE, S_IWUSR | S_IWGRP, NULL, rawdev_write); +static DEVICE_ATTR(SYSFS_AHCI_FNAME_START, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP, lba_start_read, lba_start_write); +static DEVICE_ATTR(SYSFS_AHCI_FNAME_END, S_IRUSR | S_IRGRP | S_IWUSR | S_IWGRP, lba_end_read, lba_end_write); +static DEVICE_ATTR(SYSFS_AHCI_FNAME_CURR, S_IRUSR | S_IRGRP | S_IWUSR | S_IRGRP, lba_current_read, lba_current_write); static struct attribute *root_dev_attrs[] = { &dev_attr_load_module.attr, - &dev_attr_write.attr, - &dev_attr_lba_start.attr, - &dev_attr_lba_end.attr, - &dev_attr_lba_current.attr, + &dev_attr_SYSFS_AHCI_FNAME_WRITE.attr, + &dev_attr_SYSFS_AHCI_FNAME_START.attr, + &dev_attr_SYSFS_AHCI_FNAME_END.attr, + &dev_attr_SYSFS_AHCI_FNAME_CURR.attr, NULL }; static const struct attribute_group dev_attr_root_group = { diff --git a/src/drivers/ata/ahci_elphel.h b/src/drivers/ata/ahci_elphel.h index d9c469e4c988e4826a9faeb6d55123cad4da3c34..a32fdbca0666394f7604bc5f052bd98f0cd33a13 100644 --- a/src/drivers/ata/ahci_elphel.h +++ b/src/drivers/ata/ahci_elphel.h @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -#include "../elphel/circbuf.h" +#include #ifndef _AHCI_ELPHEL_EXT #define _AHCI_ELPHEL_EXT diff --git a/src/drivers/elphel/circbuf.h b/src/drivers/elphel/circbuf.h index ec258d7ffa20357fceb28b4db787828578e933a3..6d61e1dfa01d1cd1adf594159ecf7ed797c52202 100644 --- a/src/drivers/elphel/circbuf.h +++ b/src/drivers/elphel/circbuf.h @@ -23,6 +23,7 @@ #define _CIRCBUF_H #include +#include /** @brief Circular buffer private data */ struct circbuf_priv_t { @@ -55,13 +56,6 @@ extern unsigned short circbuf_width; extern unsigned char circbuf_byrshift; /* end of debug code */ -/* this should be placed to drivers common includes */ -struct fvec { - void *iov_base; ///< pointer to allocated buffer - size_t iov_len; ///< the size (in bytes) of allocated buffer; set after allocation and is not modified during buffer lifetime - dma_addr_t iov_dma; ///< buffer physical address -}; -/* end of common includes */ int circbuf_get_ptr(int sensor_port, size_t offset, size_t len, struct fvec *vect_0, struct fvec *vect_1); #endif /* _CIRCBUF_H */ diff --git a/src/include/uapi/Kbuild b/src/include/uapi/Kbuild new file mode 100644 index 0000000000000000000000000000000000000000..0c6ea7d4b03a967abf58285ef0a74014bbcd1702 --- /dev/null +++ b/src/include/uapi/Kbuild @@ -0,0 +1,16 @@ +# UAPI Header export list +# Top-level Makefile calls into asm-$(ARCH) +# List only non-arch directories below + + +header-y += asm-generic/ +header-y += linux/ +header-y += sound/ +header-y += mtd/ +header-y += rdma/ +header-y += video/ +header-y += drm/ +header-y += xen/ +header-y += scsi/ +header-y += misc/ +header-y += elphel/ diff --git a/src/include/uapi/elphel/Kbuild b/src/include/uapi/elphel/Kbuild new file mode 100644 index 0000000000000000000000000000000000000000..a7dd4055c382cb9e3f964f234b16ec03b4d1b723 --- /dev/null +++ b/src/include/uapi/elphel/Kbuild @@ -0,0 +1,8 @@ +# UAPI Header export list +# Top-level Makefile calls into asm-$(ARCH) +# List only non-arch directories below + +#header-y += exifa.h +#header-y += c313a.h +#header-y += x393_devices.h +header-y += ahci_cmd.h diff --git a/src/include/uapi/elphel/ahci_cmd.h b/src/include/uapi/elphel/ahci_cmd.h new file mode 100644 index 0000000000000000000000000000000000000000..dd3a324eeb0e2924db1fd84316ead3de76f1d4ba --- /dev/null +++ b/src/include/uapi/elphel/ahci_cmd.h @@ -0,0 +1,63 @@ +/** @file ahci_cmd.h + * + * @brief Elphel AHCI SATA platform driver for Elphel393 camera. This module provides + * constants and data structures which are used to organize interaction between drivers + * and user space applications during JPEG files recording. + * + * @copyright Copyright (C) 2016 Elphel, Inc + * + * @par License + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef _AHCI_CMD +#define _AHCI_CMD + +#define DRV_CMD_WRITE (1 << 0) +#define DRV_CMD_FINISH (1 << 1) +#define DRV_CMD_EXIF (1 << 2) + +/** The path to Elphel AHCI driver sysfs entry. The trailing slash is mandatory. */ +#define SYSFS_AHCI_ENTRY "/sys/devices/soc0/amba@0/80000000.elphel-ahci/" +/** sysfs entry name, no double quotes. This macro is used to populate struct attribute in #ahci_elphel.c */ +#define SYSFS_AHCI_FNAME_WRITE write +/** sysfs entry name, no double quotes. This macro is used to populate struct attribute in #ahci_elphel.c */ +#define SYSFS_AHCI_FNAME_START lba_start +/** sysfs entry name, no double quotes. This macro is used to populate struct attribute in #ahci_elphel.c */ +#define SYSFS_AHCI_FNAME_END lba_end +/** sysfs entry name, no double quotes. This macro is used to populate struct attribute in #ahci_elphel.c */ +#define SYSFS_AHCI_FNAME_CURR lba_current +/** This file is used to send commands to AHCI driver from user space applications (camogm as for now). */ +#define SYSFS_AHCI_WRITE SYSFS_AHCI_ENTRY #SYSFS_AHCI_FNAME_WRITE +/** This file is used to control starting LBA of a disk buffer (R/W). */ +#define SYSFS_AHCI_LBA_START SYSFS_AHCI_ENTRY #SYSFS_AHCI_FNAME_START +/** This file is used to control ending LBA of a disk buffer (R/W). */ +#define SYSFS_AHCI_LBA_END SYSFS_AHCI_ENTRY #SYSFS_AHCI_FNAME_END +/** This file is used to control current LBA of a disk buffer (R/W). Use this file to set a pointer inside + * [lba_start..lba_end] area where next write operation will begin. */ +#define SYSFS_AHCI_LBA_CURRENT SYSFS_AHCI_ENTRY #SYSFS_AHCI_FNAME_CURR + +struct frame_data { + unsigned int sensor_port; + int cirbuf_ptr; + int jpeg_len; + int meta_index; + int cmd; +}; + +struct fvec { + void *iov_base; ///< pointer to allocated buffer + size_t iov_len; ///< the size (in bytes) of allocated buffer; set after allocation and is not modified during buffer lifetime + dma_addr_t iov_dma; ///< buffer physical address +}; + +#endif /* _AHCI_CMD */