Commit 967b475a authored by Mikhail Karpenko's avatar Mikhail Karpenko

Change processign 'finish' command

parent c6cc89b0
...@@ -68,6 +68,7 @@ static void init_vectors(struct elphel_ahci_priv *dpriv); ...@@ -68,6 +68,7 @@ static void init_vectors(struct elphel_ahci_priv *dpriv);
static void deinit_buffers(struct device *dev, struct frame_buffers *buffs); static void deinit_buffers(struct device *dev, struct frame_buffers *buffs);
static inline struct elphel_ahci_priv *dev_get_dpriv(struct device *dev); static inline struct elphel_ahci_priv *dev_get_dpriv(struct device *dev);
static void finish_cmd(struct device *dev, struct elphel_ahci_priv *dpriv); static void finish_cmd(struct device *dev, struct elphel_ahci_priv *dpriv);
static void finish_rec(struct device *dev, struct elphel_ahci_priv *dpriv, struct ata_port *port);
static int process_cmd(struct device *dev, struct elphel_ahci_priv *dpriv, struct ata_port *port); static int process_cmd(struct device *dev, struct elphel_ahci_priv *dpriv, struct ata_port *port);
//static void start_cmd(struct device *dev, struct elphel_ahci_priv *dpriv, struct ata_port *port); //static void start_cmd(struct device *dev, struct elphel_ahci_priv *dpriv, struct ata_port *port);
static inline size_t get_size_from(const struct fvec *vects, int index, size_t offset, int all); static inline size_t get_size_from(const struct fvec *vects, int index, size_t offset, int all);
...@@ -135,7 +136,7 @@ static irqreturn_t elphel_irq_handler(int irq, void * dev_instance) ...@@ -135,7 +136,7 @@ static irqreturn_t elphel_irq_handler(int irq, void * dev_instance)
dpriv->flags &= ~IRQ_SIMPLE; dpriv->flags &= ~IRQ_SIMPLE;
irq_stat = readl(port_mmio + PORT_IRQ_STAT); irq_stat = readl(port_mmio + PORT_IRQ_STAT);
dev_dbg(host->dev, "irq_stat = 0x%x, host irq_stat = 0x%x\n", irq_stat, host_irq_stat); dev_dbg(host->dev, "irq_stat = 0x%x, host irq_stat = 0x%x, time stamp: %u\n", irq_stat, host_irq_stat, get_rtc_usec());
writel(irq_stat, port_mmio + PORT_IRQ_STAT); writel(irq_stat, port_mmio + PORT_IRQ_STAT);
// writel(0xffffffff, port_mmio + PORT_IRQ_STAT); // writel(0xffffffff, port_mmio + PORT_IRQ_STAT);
...@@ -143,8 +144,13 @@ static irqreturn_t elphel_irq_handler(int irq, void * dev_instance) ...@@ -143,8 +144,13 @@ static irqreturn_t elphel_irq_handler(int irq, void * dev_instance)
writel(host_irq_stat, hpriv->mmio + HOST_IRQ_STAT); writel(host_irq_stat, hpriv->mmio + HOST_IRQ_STAT);
handled = IRQ_HANDLED; handled = IRQ_HANDLED;
if (process_cmd(host->dev, dpriv, host->ports[0]) == 0) if (process_cmd(host->dev, dpriv, host->ports[0]) == 0) {
finish_cmd(host->dev, dpriv); finish_cmd(host->dev, dpriv);
if (dpriv->flags & DELAYED_FINISH) {
dpriv->flags &= ~DELAYED_FINISH;
finish_rec(host->dev, dpriv, port);
}
}
} else { } else {
/* pass handling to AHCI level */ /* pass handling to AHCI level */
handled = ahci_single_irq_intr(irq, dev_instance); handled = ahci_single_irq_intr(irq, dev_instance);
...@@ -1175,6 +1181,7 @@ static int process_cmd(struct device *dev, struct elphel_ahci_priv *dpriv, struc ...@@ -1175,6 +1181,7 @@ static int process_cmd(struct device *dev, struct elphel_ahci_priv *dpriv, struc
dpriv->lba_ptr.wr_count = get_blocks_num(dpriv->sgl, dpriv->sg_elems); dpriv->lba_ptr.wr_count = get_blocks_num(dpriv->sgl, dpriv->sg_elems);
dma_sync_single_for_device(dev, cbuff->iov_dma, cbuff->iov_len, DMA_TO_DEVICE); dma_sync_single_for_device(dev, cbuff->iov_dma, cbuff->iov_len, DMA_TO_DEVICE);
printk(KERN_DEBUG ">>> time before issuing command: %u\n", get_rtc_usec());
elphel_cmd_issue(port, dpriv->lba_ptr.lba_write, dpriv->lba_ptr.wr_count, dpriv->sgl, dpriv->sg_elems, dpriv->curr_cmd); elphel_cmd_issue(port, dpriv->lba_ptr.lba_write, dpriv->lba_ptr.wr_count, dpriv->sgl, dpriv->sg_elems, dpriv->curr_cmd);
} }
...@@ -1263,23 +1270,28 @@ static ssize_t rawdev_write(struct device *dev, ///< ...@@ -1263,23 +1270,28 @@ static ssize_t rawdev_write(struct device *dev, ///<
size_t blocks_num; size_t blocks_num;
static int dont_process = 0; static int dont_process = 0;
if ((dpriv->flags & PROC_CMD) || dont_process) {
// we are not ready yet
return -EAGAIN;
}
if (buff_sz != sizeof(struct frame_data)) { if (buff_sz != sizeof(struct frame_data)) {
dev_err(dev, "the size of the data buffer is incorrect, should be equal to sizeof(struct frame_data)\n"); dev_err(dev, "the size of the data buffer is incorrect, should be equal to sizeof(struct frame_data)\n");
return -EINVAL; return -EINVAL;
} }
memcpy(&fdata, buff, sizeof(struct frame_data)); memcpy(&fdata, buff, sizeof(struct frame_data));
if (fdata.cmd == DRV_CMD_FINISH) { if (fdata.cmd == DRV_CMD_FINISH) {
if (!(dpriv->flags & PROC_CMD)) {
finish_rec(dev, dpriv, port); finish_rec(dev, dpriv, port);
} else {
dpriv->flags |= DELAYED_FINISH;
}
return buff_sz; return buff_sz;
} }
if ((dpriv->flags & PROC_CMD) || dont_process) {
// we are not ready yet
return -EAGAIN;
}
/* debug code follows */ /* debug code follows */
printk(KERN_DEBUG ">>> data pointers received:\n"); printk(KERN_DEBUG ">>> data pointers received, time stamp: %u\n", get_rtc_usec());
printk(KERN_DEBUG ">>> sensor port: %u\n", fdata.sensor_port); printk(KERN_DEBUG ">>> sensor port: %u\n", fdata.sensor_port);
printk(KERN_DEBUG ">>> cirbuf ptr: %d, cirbuf data len: %d\n", fdata.cirbuf_ptr, fdata.jpeg_len); printk(KERN_DEBUG ">>> cirbuf ptr: %d, cirbuf data len: %d\n", fdata.cirbuf_ptr, fdata.jpeg_len);
printk(KERN_DEBUG ">>> meta_index: %d\n", fdata.meta_index); printk(KERN_DEBUG ">>> meta_index: %d\n", fdata.meta_index);
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#define PROC_CMD (1 << 1) #define PROC_CMD (1 << 1)
/** Flag indicating that the remaining chunk of data will be recorder */ /** Flag indicating that the remaining chunk of data will be recorder */
#define LAST_BLOCK (1 << 2) #define LAST_BLOCK (1 << 2)
/** Flag indicating that recording should be stopped right after the last chunk of data
* is written */
#define DELAYED_FINISH (1 << 3)
/** The length of a command FIS in double words */ /** The length of a command FIS in double words */
#define CMD_FIS_LEN 5 #define CMD_FIS_LEN 5
/** This is used to get 28-bit address from 64-bit value */ /** This is used to get 28-bit address from 64-bit value */
......
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