From: plagnioj@jcrosoft.com (Jean-Christophe PLAGNIOL-VILLARD)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] [media] at91: add Atmel Image Sensor Interface (ISI) support
Date: Fri, 27 May 2011 14:06:29 +0200 [thread overview]
Message-ID: <20110527120629.GA3603@game.jcrosoft.org> (raw)
In-Reply-To: <1306496329-14535-1-git-send-email-josh.wu@atmel.com>
> +/* ISI interrupt service routine */
> +static irqreturn_t isi_interrupt(int irq, void *dev_id)
> +{
> + struct atmel_isi *isi = dev_id;
> + u32 status, mask, pending;
> + irqreturn_t ret = IRQ_NONE;
> +
> + spin_lock(&isi->lock);
> +
> + status = isi_readl(isi, ISI_STATUS);
> + mask = isi_readl(isi, ISI_INTMASK);
> + pending = status & mask;
> +
> + if (pending & ISI_CTRL_SRST) {
> + complete(&isi->isi_complete);
> + isi_writel(isi, ISI_INTDIS, ISI_CTRL_SRST);
> + ret = IRQ_HANDLED;
> + }
> + if (pending & ISI_CTRL_DIS) {
> + complete(&isi->isi_complete);
> + isi_writel(isi, ISI_INTDIS, ISI_CTRL_DIS);
> + ret = IRQ_HANDLED;
> + }
no else here?
> +
> + if (pending & ISI_SR_VSYNC) {
> + switch (isi->state) {
> + case ISI_STATE_IDLE:
> + isi->state = ISI_STATE_READY;
> + wake_up_interruptible(&isi->capture_wq);
> + break;
> + }
really switch here?
> + } else if (likely(pending & ISI_SR_CXFR_DONE)) {
> + ret = atmel_isi_handle_streaming(isi);
> + }
> +
> + spin_unlock(&isi->lock);
> +
> + return ret;
> +}
> +
> +#define WAIT_ISI_RESET 1
> +#define WAIT_ISI_DISABLE 0
> +static int atmel_isi_wait_status(int wait_reset, struct atmel_isi *isi)
I thinkhave teh atmel_isti first parameter is better
> +{
> + unsigned long timeout;
> + /*
> + * The reset or disable will only succeed if we have a
> + * pixel clock from the camera.
> + */
> + init_completion(&isi->isi_complete);
> +
> + if (wait_reset) {
> + isi_writel(isi, ISI_INTEN, ISI_CTRL_SRST);
> + isi_writel(isi, ISI_CTRL, ISI_CTRL_SRST);
> + } else {
> + isi_writel(isi, ISI_INTEN, ISI_CTRL_DIS);
> + isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS);
> + }
> +
> + timeout = wait_for_completion_timeout(&isi->isi_complete,
> + msecs_to_jiffies(100));
> + if (timeout == 0)
> + return -ETIMEDOUT;
> +
> + return 0;
> +}
> +
> +/* ------------------------------------------------------------------
> + Videobuf operations
> + ------------------------------------------------------------------*/
> +static int queue_setup(struct vb2_queue *vq, unsigned int *nbuffers,
> + unsigned int *nplanes, unsigned long sizes[],
> + void *alloc_ctxs[])
> +{
> + struct soc_camera_device *icd = soc_camera_from_vb2q(vq);
> + struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
> + struct atmel_isi *isi = ici->priv;
> + unsigned long size;
> + int ret, bytes_per_line;
> +
> + /* Reset ISI */
> + ret = atmel_isi_wait_status(WAIT_ISI_RESET, isi);
> + if (ret < 0) {
> + dev_err(icd->dev.parent, "Reset ISI timed out\n");
> + return ret;
> + }
> + /* Disable all interrupts */
> + isi_writel(isi, ISI_INTDIS, ~0UL);
> +
> + bytes_per_line = soc_mbus_bytes_per_line(icd->user_width,
> + icd->current_fmt->host_fmt);
> +
> + if (bytes_per_line < 0)
> + return bytes_per_line;
> +
> + size = bytes_per_line * icd->user_height;
> +
> + if (*nbuffers == 0)
> + *nbuffers = MAX_BUFFER_NUMS;
> + if (*nbuffers > MAX_BUFFER_NUMS)
else here
> + *nbuffers = MAX_BUFFER_NUMS;
> +
> + if (size * *nbuffers > VID_LIMIT_BYTES)
> + *nbuffers = VID_LIMIT_BYTES / size;
> +
> + *nplanes = 1;
> + sizes[0] = size;
> + alloc_ctxs[0] = isi->alloc_ctx;
> +
> + isi->sequence = 0;
> + isi->active = NULL;
> +
> + dev_dbg(icd->dev.parent, "%s, count=%d, size=%ld\n", __func__,
> + *nbuffers, size);
> +
> + return 0;
> +}
> +
> +static int buffer_init(struct vb2_buffer *vb)
> +{
> + struct frame_buffer *buf = container_of(vb, struct frame_buffer, vb);
> +
> + buf->p_fb_desc = NULL;
> + buf->fb_desc_phys = 0;
memset 0?
> + INIT_LIST_HEAD(&buf->list);
> +
> + return 0;
> +}
> +
otherwise the patch look good
if you fix the upper issue
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Best Regards,
J.
next prev parent reply other threads:[~2011-05-27 12:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 11:38 [PATCH v2] [media] at91: add Atmel Image Sensor Interface (ISI) support Josh Wu
2011-05-27 12:06 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2011-06-03 8:52 ` Wu, Josh
2011-05-27 13:49 ` Arnd Bergmann
2011-06-03 8:57 ` Wu, Josh
2011-05-28 20:24 ` Guennadi Liakhovetski
2011-06-03 8:28 ` Wu, Josh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110527120629.GA3603@game.jcrosoft.org \
--to=plagnioj@jcrosoft.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).