From: Hans Verkuil <hansverk@cisco.com>
To: Mauro Carvalho Chehab <m.chehab@samsung.com>,
Hans Verkuil <hverkuil@xs4all.nl>
Cc: linux-media@vger.kernel.org, stoth@kernellabs.com,
Hans Verkuil <hans.verkuil@cisco.com>
Subject: Re: [PATCHv2 15/20] cx23885: convert to vb2
Date: Wed, 03 Sep 2014 13:57:28 +0200 [thread overview]
Message-ID: <54070228.2000007@cisco.com> (raw)
In-Reply-To: <20140903083251.5c5f286c.m.chehab@samsung.com>
Hi Mauro,
On 09/03/14 13:32, Mauro Carvalho Chehab wrote:
> Em Thu, 14 Aug 2014 11:54:00 +0200
> Hans Verkuil <hverkuil@xs4all.nl> escreveu:
>
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> As usual, this patch is very large due to the fact that half a vb2 conversion
>> isn't possible. And since this affects 417, alsa, core, dvb, vbi and video the
>> changes are all over.
>>
>> What made this more difficult was the peculiar way the risc program was setup.
>> The driver allowed for running out of buffers in which case the DMA would stop
>> and restart when the next buffer was queued. There was also a complicated
>> timeout system for when buffers weren't filled. This was replaced by a much
>> simpler scheme where there is always one buffer around and the DMA will just
>> cycle that buffer until a new buffer is queued. In that case the previous
>> buffer will be chained to the new buffer. An interrupt is generated at the
>> start of the new buffer telling the driver that the previous buffer can be
>> passed on to userspace.
>>
>> Much simpler and more robust. The old code seems to be copied from the
>> cx88 driver. But it didn't fit the vb2 ops very well and replacing it with
>> the new scheme made the code easier to understand. Not to mention that this
>> patch removes 600 lines of code.
>
> Great job!
Thank you.
> Still, there are some issue. In special, the RISC changes should go
> to a separate patch, as such changes have the potential of causing
> some regressions. See below.
I tried (I mentioned that in my git pull request), but I was not able
to separate the two. I couldn't make the risc changes to work with vb1,
and the reverse would be equally painful. Not only that, but I would
have to test this twice (once with just the risc changes or vb2 changes,
and again when both are in place).
I can try to do the vb2 conversion first and the risc changes second, but
this too might be too complicated to get to work.
<snip>
>> @@ -1320,7 +1373,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
>> struct v4l2_format *f)
>> {
>> struct cx23885_dev *dev = video_drvdata(file);
>> - struct cx23885_fh *fh = file->private_data;
>>
>> f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
>> f->fmt.pix.bytesperline = 0;
>> @@ -1329,9 +1381,9 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
>> f->fmt.pix.colorspace = 0;
>> f->fmt.pix.width = dev->ts1.width;
>> f->fmt.pix.height = dev->ts1.height;
>> - f->fmt.pix.field = fh->mpegq.field;
>> - dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
>> - dev->ts1.width, dev->ts1.height, fh->mpegq.field);
>> + f->fmt.pix.field = V4L2_FIELD_INTERLACED;
>
> Why? There are other supported formats, right?
Not for the compressed video node. Only MPEG is supported there.
>
>> + dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d\n",
>> + dev->ts1.width, dev->ts1.height);
>> return 0;
>> }
>>
>> @@ -1339,15 +1391,15 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
>> struct v4l2_format *f)
>> {
>> struct cx23885_dev *dev = video_drvdata(file);
>> - struct cx23885_fh *fh = file->private_data;
>>
>> f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
>> f->fmt.pix.bytesperline = 0;
>> f->fmt.pix.sizeimage =
>> dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
>> f->fmt.pix.colorspace = 0;
>> - dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
>> - dev->ts1.width, dev->ts1.height, fh->mpegq.field);
>> + f->fmt.pix.field = V4L2_FIELD_INTERLACED;
>
> Why? There are other supported formats, right?
Ditto.
>
>> + dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d\n",
>> + dev->ts1.width, dev->ts1.height);
>> return 0;
>> }
>>
<snip>
>>
>> int cx23885_sram_channel_setup(struct cx23885_dev *dev,
>> @@ -482,8 +466,8 @@ int cx23885_sram_channel_setup(struct cx23885_dev *dev,
>> lines = 6;
>> BUG_ON(lines < 2);
>>
>> - cx_write(8 + 0, RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
>> - cx_write(8 + 4, 8);
>> + cx_write(8 + 0, RISC_JUMP | RISC_CNT_RESET);
>> + cx_write(8 + 4, 12);
>
> The above doesn't sound as being a pure vb2 conversion, and might cause
> regressions, as we're changing the channel setups. I would very much
> prefer to have such changes on a separate changeset, as it makes easier
> to do bisect if ever needed.
See my comment at the top.
>
>> cx_write(8 + 8, 0);
>>
>> /* write CDT */
>> @@ -699,10 +683,6 @@ static int get_resources(struct cx23885_dev *dev)
>> return -EBUSY;
>> }
>>
>> -static void cx23885_timeout(unsigned long data);
>> -int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
>> - u32 reg, u32 mask, u32 value);
>> -
>> static int cx23885_init_tsport(struct cx23885_dev *dev,
>> struct cx23885_tsport *port, int portno)
>> {
>> @@ -719,11 +699,6 @@ static int cx23885_init_tsport(struct cx23885_dev *dev,
>> port->nr = portno;
>>
>> INIT_LIST_HEAD(&port->mpegq.active);
>> - INIT_LIST_HEAD(&port->mpegq.queued);
>> - port->mpegq.timeout.function = cx23885_timeout;
>> - port->mpegq.timeout.data = (unsigned long)port;
>> - init_timer(&port->mpegq.timeout);
>> -
>> mutex_init(&port->frontends.lock);
>> INIT_LIST_HEAD(&port->frontends.felist);
>> port->frontends.active_fe_id = 0;
>> @@ -776,9 +751,6 @@ static int cx23885_init_tsport(struct cx23885_dev *dev,
>> BUG();
>> }
>>
>> - cx23885_risc_stopper(dev->pci, &port->mpegq.stopper,
>> - port->reg_dma_ctl, port->dma_ctl_val, 0x00);
>> -
>> return 0;
>> }
>>
>> @@ -1089,11 +1061,18 @@ static void cx23885_dev_unregister(struct cx23885_dev *dev)
>> static __le32 *cx23885_risc_field(__le32 *rp, struct scatterlist *sglist,
>> unsigned int offset, u32 sync_line,
>> unsigned int bpl, unsigned int padding,
>> - unsigned int lines, unsigned int lpi)
>> + unsigned int lines, unsigned int lpi, bool jump)
>> {
>> struct scatterlist *sg;
>> unsigned int line, todo, sol;
>>
>> +
>> + if (jump) {
>> + *(rp++) = cpu_to_le32(RISC_JUMP);
>> + *(rp++) = cpu_to_le32(0);
>> + *(rp++) = cpu_to_le32(0); /* bits 63-32 */
>> + }
>> +
>
> Here it seem clear: you're now adding a code to support different
> frame interlacing layouts, but the best is to have such changes on
> a separate changeset, as this is one thing that we may have troubles
> in the future.
>
> The way I see is that we might start having a flood of complains about
> regressions, and all of them will point to this single patch, making
> really hard to identify what part of the change broke it.
>
> So, let's split those risc changes on a pre (or post) patch, making
> easier if someone needs to report an issue, for us to track what
> patch broke it.
>
>> /* sync instruction */
>> if (sync_line != NO_SYNC_LINE)
>> *(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
>> @@ -1168,7 +1147,7 @@ int cx23885_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
>> /* write and jump need and extra dword */
>> instructions = fields * (1 + ((bpl + padding) * lines)
>> / PAGE_SIZE + lines);
>> - instructions += 2;
>> + instructions += 5;
>> rc = btcx_riscmem_alloc(pci, risc, instructions*12);
>> if (rc < 0)
>> return rc;
>> @@ -1177,10 +1156,10 @@ int cx23885_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
>> rp = risc->cpu;
>> if (UNSET != top_offset)
>> rp = cx23885_risc_field(rp, sglist, top_offset, 0,
>> - bpl, padding, lines, 0);
>> + bpl, padding, lines, 0, true);
>> if (UNSET != bottom_offset)
>> rp = cx23885_risc_field(rp, sglist, bottom_offset, 0x200,
>> - bpl, padding, lines, 0);
>> + bpl, padding, lines, 0, UNSET == top_offset);
>>
>> /* save pointer to jmp instruction address */
>> risc->jmp = rp;
>> @@ -1204,7 +1183,7 @@ int cx23885_risc_databuffer(struct pci_dev *pci,
>> than PAGE_SIZE */
>> /* Jump and write need an extra dword */
>> instructions = 1 + (bpl * lines) / PAGE_SIZE + lines;
>> - instructions += 1;
>> + instructions += 4;
>>
>> rc = btcx_riscmem_alloc(pci, risc, instructions*12);
>> if (rc < 0)
>> @@ -1213,7 +1192,7 @@ int cx23885_risc_databuffer(struct pci_dev *pci,
>> /* write risc instructions */
>> rp = risc->cpu;
>> rp = cx23885_risc_field(rp, sglist, 0, NO_SYNC_LINE,
>> - bpl, 0, lines, lpi);
>> + bpl, 0, lines, lpi, lpi == 0);
>>
>> /* save pointer to jmp instruction address */
>> risc->jmp = rp;
>> @@ -1243,7 +1222,7 @@ int cx23885_risc_vbibuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
>> /* write and jump need and extra dword */
>> instructions = fields * (1 + ((bpl + padding) * lines)
>> / PAGE_SIZE + lines);
>> - instructions += 2;
>> + instructions += 5;
>> rc = btcx_riscmem_alloc(pci, risc, instructions*12);
>> if (rc < 0)
>> return rc;
>> @@ -1253,12 +1232,12 @@ int cx23885_risc_vbibuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
>> /* Sync to line 6, so US CC line 21 will appear in line '12'
>> * in the userland vbi payload */
>> if (UNSET != top_offset)
>> - rp = cx23885_risc_field(rp, sglist, top_offset, 6,
>> - bpl, padding, lines, 0);
>> + rp = cx23885_risc_field(rp, sglist, top_offset, 0,
>> + bpl, padding, lines, 0, true);
>>
>> if (UNSET != bottom_offset)
>> - rp = cx23885_risc_field(rp, sglist, bottom_offset, 0x207,
>> - bpl, padding, lines, 0);
>> + rp = cx23885_risc_field(rp, sglist, bottom_offset, 0x200,
>> + bpl, padding, lines, 0, UNSET == top_offset);
>
> Why to change the 4th argument of cx23885_risc_field() call?
This was a bug. Hmm, perhaps that should be moved to a separate patch.
The VBI offset was wrong without this.
>
>>
>>
>>
>> @@ -1269,38 +1248,10 @@ int cx23885_risc_vbibuffer(struct pci_dev *pci, struct btcx_riscmem *risc,
>> }
>>
>>
>> -int cx23885_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
>> - u32 reg, u32 mask, u32 value)
>
> What happened with this function?
No longer needed after the risc changes.
Regards,
Hans
next prev parent reply other threads:[~2014-09-03 11:58 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-14 9:53 [PATCHv2 00/20] cx23885: convert to the V4L2 core frameworks Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 01/20] cx23885: fix querycap Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 02/20] cx23885: fix audio input handling Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 03/20] cx23885: support v4l2_fh and g/s_priority Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 04/20] cx23885: use core locking, switch to unlocked_ioctl Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 05/20] cx23885: convert to the control framework Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 06/20] cx23885: convert 417 " Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 07/20] cx23885: fix format colorspace compliance error Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 08/20] cx23885: map invalid fields to a valid field Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 09/20] cx23885: drop radio-related dead code Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 10/20] cx23885: drop type field from struct cx23885_fh Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 11/20] cx23885: drop unused clip fields " Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 12/20] cx23885: fmt, width and height are global, not per-fh Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 13/20] cx23885: drop videobuf abuse in cx23885-alsa Hans Verkuil
2014-08-14 9:53 ` [PATCHv2 14/20] cx23885: use video_drvdata to get cx23885_dev pointer Hans Verkuil
2014-08-14 9:54 ` [PATCHv2 15/20] cx23885: convert to vb2 Hans Verkuil
2014-09-03 11:32 ` Mauro Carvalho Chehab
2014-09-03 11:57 ` Hans Verkuil [this message]
2014-09-03 12:17 ` Mauro Carvalho Chehab
2014-08-14 9:54 ` [PATCHv2 16/20] cx23885: fix field handling Hans Verkuil
2014-08-14 9:54 ` [PATCHv2 17/20] cx23885: fix weird sizes Hans Verkuil
2014-09-03 11:46 ` Mauro Carvalho Chehab
2014-09-03 12:07 ` Hans Verkuil
2014-09-03 12:16 ` Mauro Carvalho Chehab
2014-09-05 9:29 ` Hans Verkuil
2014-08-14 9:54 ` [PATCHv2 18/20] cx23885: remove FSF address as per checkpatch Hans Verkuil
2014-08-14 9:54 ` [PATCHv2 19/20] cx23885: remove btcx-risc dependency Hans Verkuil
2014-08-14 9:54 ` [PATCHv2 20/20] cx23885: Add busy checks before changing formats Hans Verkuil
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=54070228.2000007@cisco.com \
--to=hansverk@cisco.com \
--cc=hans.verkuil@cisco.com \
--cc=hverkuil@xs4all.nl \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
--cc=stoth@kernellabs.com \
/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).