summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform/ti-vpe/vpe.c
Commit message (Collapse)AuthorAgeFilesLines
* media: platform: make video_device constBhumika Goyal2017-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make these const as they are only used during a copy operation. Done using Coccinelle: @match disable optional_qualifier@ identifier s; @@ static struct video_device s = {...}; @ref@ position p; identifier match.s; @@ s@p @good1@ identifier match.s; expression list[3] es; position ref.p; @@ cx88_vdev_init(es,&s@p,...) @good2@ position ref.p; identifier match.s,f,c; expression e; @@ ( e = s@p | e = s@p.f | c(...,s@p.f,...) | c(...,s@p,...) ) @bad depends on !good1 && !good2@ position ref.p; identifier match.s; @@ s@p @depends on forall !bad disable optional_qualifier@ identifier match.s; @@ static + const struct video_device s; Signed-off-by: Bhumika Goyal <bhumirks@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* media: ti-vpe: vpe: constify v4l2_m2m_ops structuresJulia Lawall2017-08-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The v4l2_m2m_ops structures are only passed as the only argument to v4l2_m2m_init, which is declared as const. Thus the v4l2_m2m_ops structures themselves can be const. Done with the help of Coccinelle. // <smpl> @r disable optional_qualifier@ identifier i; position p; @@ static struct v4l2_m2m_ops i@p = { ... }; @ok1@ identifier r.i; position p; @@ v4l2_m2m_init(&i@p) @bad@ position p != {r.p,ok1.p}; identifier r.i; struct v4l2_m2m_ops e; @@ e@i@p @depends on !bad disable optional_qualifier@ identifier r.i; @@ static +const struct v4l2_m2m_ops i = { ... }; // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: allow use of user specified strideBenoit Parrot2017-03-031-8/+20
| | | | | | | | | | | | | | Bytesperline/stride was always overwritten by VPE to the most adequate value based on needed alignment. However in order to make use of arbitrary size DMA buffer it is better to use the user space provide stride instead. The driver will still calculate an appropriate stride but will use the provided one when it is larger than the calculated one. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpdma: add support for user specified strideBenoit Parrot2017-03-031-2/+4
| | | | | | | | | This patch introduce the needed vpdma API changes to support user space specified stride instead of forcing a driver calculated one. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ti-vpe: get rid of some smatch warningsMauro Carvalho Chehab2016-11-221-3/+15
| | | | | | | | | | | | | | | | | | | | | When compiled on i386, it produces several warnings: ./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue ./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue ./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue ./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue ./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue ./arch/x86/include/asm/bitops.h:457:22: warning: asm output is not an lvalue I suspect that some gcc optimization could be causing the asm code to be incorrectly generated. Splitting it into two macro calls fix the issues and gets us rid of 6 smatch warnings, with is a good thing. As it should not cause any troubles, as we're basically doing the same thing, let's apply such change to vpe.c. Cc: Benoit Parrot <bparrot@ti.com> Cc: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Add proper support single and multi-plane bufferBenoit Parrot2016-11-221-10/+48
| | | | | | | | | | | | | | | | | | | | The VPE was restricting the number of plane per buffer based on the fact that if a particular format had color separation it was meant to need 2 planes. However NV12/NV16 are color separate format which are meant to be presented in a single contiguous buffer/plane. It could also be presented in a multi-plane as well if need be. So we must support both modes for more flexibility. The number of plane requested by user space was previously ignored and was therefore always overwritten. The driver now use the requested num plane as hint to calculate needed offset when required. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: Make colorspace converter library into its own moduleBenoit Parrot2016-11-221-1/+1
| | | | | | | | | In preparation to add colorspace conversion support to VIP, we need to turn csc.c into its own kernel module. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Make sure frame size dont exceed scaler capacityBenoit Parrot2016-11-221-17/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | When scaler is to be used we need to make sure that the input and output frame size do not exceed the maximum frame sizes that the scaler h/w can handle otherwise streaming stall as the scaler cannot proceed. The scaler buffer is limited to 2047 pixels (i.e. 11 bits) when attempting anything larger (2048 for example) the scaler stalls. Realistically in an mem2mem device we can only check for this type of issue when start_streaming is called. We can't do it during the try_fmt/s_fmt because we do not have all of the info needed at that point. So instead when start_streaming is called we need to check that the input and output frames size do not exceed the scaler's capability. The only time larger frame size are allowed is when the input frame szie is the same as the output frame size. Now in the case where we need to fail, start_streaming must return all previously queued buffer back otherwise the vb2 framework will issue kernel WARN messages. In this case we also give an error message. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: Make scaler library into its own moduleBenoit Parrot2016-11-221-1/+1
| | | | | | | | | | | | | | In preparation to add scaler support into VIP we need to turn sc.c into its own kernel module. Add support for multiple SC memory block as VIP contains 2 scaler instances. This is done by passing the resource name to sc_create() and modify the vpe invocation accordingly. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Enable DMABUF exportBenoit Parrot2016-11-221-0/+1
| | | | | | | | Allow VPE to be able to export DMA buffer. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Fix line stride for output motion vectorNikhil Devshatwar2016-11-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | For deinterlacing operation, VPE hardware uses motion vectors. MV calculated in the previous iteration are used for next interation. Therefore driver allocates two motion vectors in ping-pong fashion. For every transaction, one MV is DMAed in and one is DMAed out. All the outbound DMAs (DMA to memory) use output parameters, but as the motion vectors is generated purely out of input fields, it should use the input parameters for DMA. Fix the add_out_dtd to use source q_data for creating descriptor. If the output size is greater than input stride, without this change, MV DMA may overwrite the buffer causing memory corruption. This CRITICAL fix ensures that the motion vector DMA descriptor is created based on the attributes with which the buffer was allocated. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Ravikumar Kattekola <rk@ti.com> Signed-off-by: Ravi Babu <ravibabu@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpdma: Fix race condition for firmware loadingNikhil Devshatwar2016-11-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | vpdma_create API is supposed to allocated the struct vpdma_data and return it to the driver. Also, it would call the callback function when the VPDMA firmware is loaded. Typically, VPE driver have following function call: dev->vpdma = vpdma_create(pdev, firmware_load_callback); And the callback implementation would continue the probe further. Also, the dev->vpdma is accessed from the callback implementation. This may lead to race condition between assignment of dev->vpdma and the callback function being triggered. This would lead to kernel crash because of NULL pointer access. Fix this by passing a driver wrapped &vpdma_data instead of allocating inside vpdma_create. Change the vpdma_create prototype accordingly and fix return paths. Also, update the VPE driver to use the updated API and initialize the dev->vpdma before hand so that the race condition is avoided. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Fix vb2 buffer cleanupBenoit Parrot2016-11-221-2/+60
| | | | | | | | | | | | | | | | When stop_streaming is called we need to cleanup the queued vb2 buffers properly. This was not previously being done which caused kernel warning when the application using the resources was killed. Kernel warnings were also generated on successful completion of a de-interlacing case as well as upon aborting a conversion. Make sure every vb2 buffers is properly handled in all cases. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpdma: Corrected YUV422 data type labelBenoit Parrot2016-11-221-4/+4
| | | | | | | | | | | | | | | | | | The YUV data type definition below are taken from both the TRM and i839 Errata information. Use the correct data type considering byte reordering of components. Added the 2 missing YUV422 variant. Also since the single use of "C" in the 422 case to mean "Cr" (i.e. V component). It was decided to explicitly label them CR to remove any confusion. Bear in mind that the type label refer to the memory packed order (LSB - MSB). Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Added MODULE_DEVICE_TABLE hintBenoit Parrot2016-11-221-0/+1
| | | | | | | | | | ti_vpe module currently does not get loaded automatically. Added MODULE_DEVICE_TABLE hint to the driver to assist. Signed-off-by: Benoit Parrot <bparrot@ti.com> Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Add RGB565 and RGB5551 supportNikhil Devshatwar2016-11-221-2/+20
| | | | | | | | | | | | | | VPE hardware can generate output in RGB565 or in RGB5551 format. Add these formats in the supported format list for CAPTURE stream. Also, for RGB5551 format, the alpha component is not processed, so the alpha value is taken from the default color. Set the default color to make alpha component full when the dst format is of RGB color space. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Post next descriptor only for list complete IRQNikhil Devshatwar2016-11-221-0/+9
| | | | | | | | | | | | | | | | | vpe_irq checks for the possible interrupt sources and prints the errors for the DEI_ERROR and DS_UV interrupts. But it also post the next descriptor list irrespective of whichever interrupt has occurred. Because of this, driver may release the buffers even before DMA is complete and also schedule next descriptor list. Fix this by _actually_ handling the IRQ only when ListComplete IRQ occurs. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Setup srcdst parameters in start_streamingNikhil Devshatwar2016-11-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | For deinterlacing operation, each operation needs 2 fields in the history. This is achieved by holding three buffers in ctx->src_vbs[0,1,2] (f,f-1,f-2) This is achieved by using the ctx->sequence which gets reset via the s_fmt ioctl. These buffers are dequeued in stream OFF by calling free_vbs() But the corresponding references aren't removed anywhere. When application tries to stream ON and OFF continuously, s_fmt ioctl won't be called and it won't setup the srcdst parameters. Setting source/destination parameters in stream ON ioctl would make sure that the context is re-initialized before it is being used by the driver. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: configure line mode separatelyNikhil Devshatwar2016-11-221-8/+17
| | | | | | | | | | | | | | | | | | | | | | | Current driver configures the line mode of the DEI clients from the open function directly. Even if the newly created context is not yet scheduled, it updates some of the VPDMA registers. This causes a problem in multi instance use case where just opening the m2m device second time causes the running job to stall. This happens especially if the source buffers used are NV12. While all other configuration is being written to context specific shadow registers, only line mode configuration is happening directly. As there is no shadow register for line mode configuration, it's better to separate the config_mode setting and line_mode setting. Call the new "set_line_modes" functions only when actually loading the mmrs. This makes sure that no non-running job will write to the registers directly. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpdma: Clear IRQs for individual listsNikhil Devshatwar2016-11-221-1/+1
| | | | | | | | | | | VPDMA IRQs are registered for multiple lists When clearing an IRQ for a list interrupt, all the IRQs for the individual lists are to be cleared separately. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpdma: Add support for setting max width heightNikhil Devshatwar2016-11-221-1/+6
| | | | | | | | | | | | | | | | | | | Add a helper function to be able to set the maximum VPDMA transfer size to limit potential buffer overrun. Added enums for max_width and max_height fields of the outbound data descriptor. Changed vpdma_add_out_dtd to accept two more arguments for max width and height. Make use of different max width & height sets for different of capture module (i.e. slices). Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: Free vpdma buffers in vpe_releaseHarinarayan Bhatta2016-11-221-0/+3
| | | | | | | | | | | | Free vpdma buffers in vpe_release. Otherwise it was generating random backtrace. Signed-off-by: Harinarayan Bhatta <harinarayan@ti.com> Signed-off-by: Somnath Mukherjee <somnath@ti.com> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Return NULL for invalid buffer typeNikhil Devshatwar2016-11-221-1/+1
| | | | | | | | | | | | | | | get_q_data can be called with different values for type e.g. vpe_try_crop calls it with the buffer type which gets passed from user space Framework doesn't check wheather its correct type or not If user space passes wrong type, kernel should not crash. Return NULL when the passed type is invalid. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: Increasing max buffer height and widthHarinarayan Bhatta2016-11-221-2/+2
| | | | | | | | | | Increasing max buffer height and width to allow for padded buffers. Signed-off-by: Harinarayan Bhatta <harinarayan@ti.com> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: Add support for SEQ_TB buffersNikhil Devshatwar2016-11-221-22/+103
| | | | | | | | | | | | | | | | | | The video source can generate the data in the SEQ_TB buffer format. In the case of TI SoC, the IVA_HD can generate the interlaced content in the SEQ_TB buffer format. This is the format where the top and bottom field data can be contained in a single buffer. For example, for NV12, interlaced format, the data in Y buffer will be arranged as Y-top followed by Y-bottom. And likewise for UV plane. Also, queuing one buffer of SEQ_TB is equivalent to queuing two different buffers for top and bottom fields. Driver needs to take care of this when handling source buffer lists. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpe: Do not perform job transaction atomicallyNikhil Devshatwar2016-11-221-16/+16
| | | | | | | | | | | | | | | | | | | | | | | Current VPE driver does not start the job until all the buffers for a transaction are queued. When running in multiple context, this might increase the processing latency. Alternate solution would be to try to continue the same context as long as buffers for the transaction are ready; else switch the context. This may increase number of context switches but it reduces latency significantly. In this approach, the job_ready always succeeds as long as there are buffers on the CAPTURE and OUTPUT stream. Processing may start immediately as the first 2 iterations don't need extra source buffers. Shift all the source buffers after each iteration and remove the oldest buffer. Also, with this removes the constraint of pre buffering 3 buffers before call to STREAMON in case of de-interlacing. Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: Use line average de-interlacing for first 2 framesArchit Taneja2016-11-221-2/+31
| | | | | | | | | | | | | | | | | | | | | The motion detection block requires 3 fields to create the motion vector data. This means that using the default method the first progressive frame is only generated after 3rd field is consumed. Hence by default for N input field we would generate N - 2 progressive frames. In order to generate N progressive frames from N fields we use the line averaging mode of the de-interlacer for the first 2 fields and then revert back to the preferred Edge Directed Interpolation method (using the motion vector). Thus creating 2 line averaged frames + N - 2 motion based frames for a total of N frames. Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com> Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: ti-vpe: vpdma: Add multi-instance and multi-client supportBenoit Parrot2016-11-221-4/+4
| | | | | | | | | | | | | | | | The VPDMA (Video Port DMA) as found in devices such as DRA7xx is used for both the Video Processing Engine (VPE) and the Video Input Port (VIP). Some devices may have multiple VIP instances each with its own VPDMA engine. Within VIP two slices can use a single VPDMA engine simultaneously. So support for multi instances and multiple clients has been added to VPDMA. Needed modification to the existing helper functions were then reflected to VPE. Multi-clients registers offset have also been added in preparation. Signed-off-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] ti-vpe: don't break long linesMauro Carvalho Chehab2016-10-211-2/+1Star
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Due to the 80-cols restrictions, and latter due to checkpatch warnings, several strings were broken into multiple lines. This is not considered a good practice anymore, as it makes harder to grep for strings at the source code. As we're right now fixing other drivers due to KERN_CONT, we need to be able to identify what printk strings don't end with a "\n". It is a way easier to detect those if we don't break long lines. So, join those continuation lines. The patch was generated via the script below, and manually adjusted if needed. </script> use Text::Tabs; while (<>) { if ($next ne "") { $c=$_; if ($c =~ /^\s+\"(.*)/) { $c2=$1; $next =~ s/\"\n$//; $n = expand($next); $funpos = index($n, '('); $pos = index($c2, '",'); if ($funpos && $pos > 0) { $s1 = substr $c2, 0, $pos + 2; $s2 = ' ' x ($funpos + 1) . substr $c2, $pos + 2; $s2 =~ s/^\s+//; $s2 = ' ' x ($funpos + 1) . $s2 if ($s2 ne ""); print unexpand("$next$s1\n"); print unexpand("$s2\n") if ($s2 ne ""); } else { print "$next$c2\n"; } $next=""; next; } else { print $next; } $next=""; } else { if (m/\"$/) { if (!m/\\n\"$/) { $next=$_; next; } } } print $_; } </script> Acked-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] platform: constify vb2_ops structuresJulia Lawall2016-09-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Check for vb2_ops structures that are only stored in the ops field of a vb2_queue structure. That field is declared const, so vb2_ops structures that have this property can be declared as const also. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r disable optional_qualifier@ identifier i; position p; @@ static struct vb2_ops i@p = { ... }; @ok@ identifier r.i; struct vb2_queue e; position p; @@ e.ops = &i@p; @bad@ position p != {r.p,ok.p}; identifier r.i; struct vb2_ops e; @@ e@i@p @depends on !bad disable optional_qualifier@ identifier r.i; @@ static +const struct vb2_ops i = { ... }; // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Fabien Dessenne <fabien.dessenne@st.com> Reviewed-by: Jacek Anaszewski <j.anaszewski@samsung.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> [hans.verkuil@cisco.com: dropped soc_camera/rcar_vin.c patch because that driver will be removed] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] vb2: replace void *alloc_ctxs by struct device *alloc_devsHans Verkuil2016-07-081-1/+1
| | | | | | | | | | | | | | | | Make this a proper typed array. Drop the old allocate context code since that is no longer used. Note that the memops functions now get a struct device pointer instead of the struct device ** that was there initially (actually a void pointer to a struct containing only a struct device pointer). This code is now a lot cleaner. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media/platform: convert drivers to use the new vb2_queue dev fieldHans Verkuil2016-07-081-16/+4Star
| | | | | | | | | | Stop using alloc_ctx and just fill in the device pointer. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Fabien Dessenne <fabien.dessenne@st.com> Acked-by: Benoit Parrot <bparrot@ti.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
* [media] media: videobuf2: Move timestamp to vb2_bufferJunghak Sung2015-12-181-1/+1
| | | | | | | | | | | | | | Move timestamp from struct vb2_v4l2_buffer to struct vb2_buffer for common use, and change its type to u64 in order to handling y2038 problem. This patch also includes all device drivers' changes related to this restructuring. Signed-off-by: Junghak Sung <jh1009.sung@samsung.com> Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com> Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com> Acked-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Hans Verkuil <hansverk@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] vb2: drop v4l2_format argument from queue_setupHans Verkuil2015-12-181-1/+0Star
| | | | | | | | | | | | | | | | | | | | | The queue_setup callback has a void pointer that is just for V4L2 and is the pointer to the v4l2_format struct that was passed to VIDIOC_CREATE_BUFS. The idea was that drivers would use the information from that struct to buffers suitable for the requested format. After the vb2 split series this pointer is now a void pointer, which is ugly, and the reality is that all existing drivers will effectively just look at the sizeimage field of v4l2_format. To make this more generic the queue_setup callback is changed: the void pointer is dropped, instead if the *num_planes argument is 0, then use the current format size, if it is non-zero, then it contains the number of requested planes and the sizes array contains the requested sizes. If either is unsupported, then return -EINVAL, otherwise use the requested size(s). Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: videobuf2: Change queue_setup argumentJunghak Sung2015-10-201-1/+1
| | | | | | | | | | | | | | | Replace struct v4l2_format * with void * to make queue_setup() for common use. And then, modify all device drivers related with this change. Signed-off-by: Junghak Sung <jh1009.sung@samsung.com> Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com> Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com> Acked-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> [hans.verkuil@cisco.com: fix missing const in fimc-lite.c] Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: videobuf2: Restructure vb2_bufferJunghak Sung2015-10-011-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove v4l2 stuff - v4l2_buf, v4l2_plane - from struct vb2_buffer. Add new member variables - bytesused, length, offset, userptr, fd, data_offset - to struct vb2_plane in order to cover all information of v4l2_plane. struct vb2_plane { <snip> unsigned int bytesused; unsigned int length; union { unsigned int offset; unsigned long userptr; int fd; } m; unsigned int data_offset; } Replace v4l2_buf with new member variables - index, type, memory - which are common fields for buffer management. struct vb2_buffer { <snip> unsigned int index; unsigned int type; unsigned int memory; unsigned int num_planes; struct vb2_plane planes[VIDEO_MAX_PLANES]; <snip> }; v4l2 specific fields - flags, field, timestamp, timecode, sequence - are moved to vb2_v4l2_buffer in videobuf2-v4l2.c struct vb2_v4l2_buffer { struct vb2_buffer vb2_buf; __u32 flags; __u32 field; struct timeval timestamp; struct v4l2_timecode timecode; __u32 sequence; }; Signed-off-by: Junghak Sung <jh1009.sung@samsung.com> Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com> Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com> Acked-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: videobuf2: Replace videobuf2-core with videobuf2-v4l2Junghak Sung2015-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make videobuf2-v4l2 as a wrapper of videobuf2-core for v4l2-use. And replace videobuf2-core.h with videobuf2-v4l2.h. This renaming change should be accompanied by the modifications of all device drivers that include videobuf2-core.h. It can be done with just running this shell script. replace() { str1=$1 str2=$2 dir=$3 for file in $(find $dir -name *.h -o -name *.c -o -name Makefile) do echo $file sed "s/$str1/$str2/g" $file > $file.out mv $file.out $file done } replace "videobuf2-core" "videobuf2-v4l2" "include/media/" replace "videobuf2-core" "videobuf2-v4l2" "drivers/media/" replace "videobuf2-core" "videobuf2-v4l2" "drivers/usb/gadget/" replace "videobuf2-core" "videobuf2-v4l2" "drivers/staging/media/" Signed-off-by: Junghak Sung <jh1009.sung@samsung.com> Signed-off-by: Geunyoung Kim <nenggun.kim@samsung.com> Acked-by: Seung-Woo Kim <sw0312.kim@samsung.com> Acked-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: ti-vpe: Use mem-to-mem ioctl helpersPrabhakar Lad2015-02-021-107/+50Star
| | | | | | | | | | | | | 1: Simplify the vpe mem-to-mem driver by using the m2m ioctl and vb2 helpers. 2: Align and arranged the v4l2_ioctl_ops. 3: Fixes a typo. 4: Use of_match_ptr() instead of explicitly defining the macro to NULL in case CONFIG_OF is not defined. Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] media: ti-vpe: use vb2_ops_wait_prepare/finish helperPrabhakar Lad2014-12-221-14/+5Star
| | | | | | | | | | | | | | This patch drops driver specific wait_prepare() and wait_finish() callbacks from vb2_ops and instead uses the the helpers vb2_ops_wait_prepare/finish() provided by the vb2 core, the lock member of the queue needs to be initalized to a mutex so that vb2 helpers vb2_ops_wait_prepare/finish() can make use of it. Signed-off-by: Lad, Prabhakar <prabhakar.csengg@gmail.com> Cc: Kukjin Kim <kgene.kim@samsung.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* media: platform: ti-vpe: drop owner assignment from platform_driversWolfram Sang2014-10-201-1/+0Star
| | | | | | | A platform_driver does not need to set an owner, it will be populated by the driver core. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
* [media] v4l: ti-vpe: Remove casting the return value which is a void pointerJingoo Han2014-09-231-2/+1Star
| | | | | | | | | Casting the return value which is a void pointer is redundant. The conversion from void pointer to any other pointer type is guaranteed by the C programming language. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] v4l: ti-vpe: use c99 initializers in structuresJulia Lawall2014-09-221-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use c99 initializers for structures. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @decl@ identifier i1,fld; type T; field list[n] fs; @@ struct i1 { fs T fld; ...}; @bad@ identifier decl.i1,i2; expression e; initializer list[decl.n] is; @@ struct i1 i2 = { is, + .fld = e - e ,...}; // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
* [media] ti-vpe: use true/false for boolean varsMauro Carvalho Chehab2014-09-031-2/+2
| | | | | | | Instead of using 0 or 1 for boolean, use the true/false defines. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] enable COMPILE_TEST for ti-vbeMauro Carvalho Chehab2014-08-261-0/+1
| | | | | | | | | | | | Allowing COMPILE_TEST here is trivial, but there's one missing header to be added: drivers/media/platform/ti-vpe/vpe.c: In function ‘vpe_probe’: drivers/media/platform/ti-vpe/vpe.c:2266:56: error: ‘SZ_32K’ undeclared (first use in this function) dev->base = devm_ioremap(&pdev->dev, dev->res->start, SZ_32K); ^ Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: ti-vpe: Add selection API in VPE driverArchit Taneja2014-05-231-0/+150
| | | | | | | | | | | | | | | | | | Add selection ioctl ops. For VPE, cropping makes sense only for the input to VPE(or V4L2_BUF_TYPE_VIDEO_OUTPUT/MPLANE buffers) and composing makes sense only for the output of VPE(or V4L2_BUF_TYPE_VIDEO_CAPTURE/MPLANE buffers). For the CAPTURE type, V4L2_SEL_TGT_COMPOSE results in VPE writing the output in a rectangle within the capture buffer. For the OUTPUT type, V4L2_SEL_TGT_CROP results in selecting a rectangle region within the source buffer. Setting the crop/compose rectangles should successfully result in re-configuration of registers which are affected when either source or destination dimensions change, set_srcdst_params() is called for this purpose. Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: ti-vpe: Fix some params in VPE data descriptorsArchit Taneja2014-05-231-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some parameters of the VPE descriptors were understood incorrectly. They are now fixed. The fixes are explained as follows: - When adding an inbound data descriptor to the VPDMA descriptor list, we intend to use c_rect as the cropped region fetched by VPDMA. Therefore, c_rect->width shouldn't be used to calculate the line stride, the original image width should be used for that. We add a 'width' argument which gives the buffer width in memory. - frame_width and frame_height describe the complete width and height of the client to which the channel is connected. If there are multiple channels fetching data and providing to the same client, the above 2 arguments should be the width and height of the region covered by all the channels. In the case where there is only one channel providing pixel data to the client (like in VPE), frame_width and frame_height should be the cropped width and cropped height respectively. The calculation of these params is done in the vpe driver now. - start_h and start_v is also used in the case of multiple channels to describe where each channel should start filling pixel data. We don't use this in VPE, and pass 0s to the vpdma_add_in_dtd() helper. - Some minor changes are made to the vpdma_add_out_dtd() helper. The c_rect param is used for specifying the 'composition' target, and 'width' is added to calculate the line stride. Signed-off-by: Archit Taneja <archit@ti.com> Acked-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: ti-vpe: Allow DMABUF buffer type supportArchit Taneja2014-05-231-2/+2
| | | | | | | | | | | | | | | For OMAP and DRA7x, we generally allocate video and graphics buffers through omapdrm since the corresponding omap-gem driver provides DMM-Tiler backed contiguous buffers. omapdrm is a dma-buf exporter. These buffers are used by other drivers in the video pipeline. Add VB2_DMABUF flag to the io_modes of the vb2 output and capture queues. This allows the driver to import dma shared buffers. Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: ti-vpe: register video device only when firmware is loadedArchit Taneja2014-05-231-23/+32
| | | | | | | | | | | | | | | | | | | | | | | | | vpe fops(vpe_open in particular) should be called only when VPDMA firmware is loaded. File operations on the video device are possible the moment it is registered. Currently, we register the video device for VPE at driver probe, after calling a vpdma helper to initialize VPDMA and load firmware. This function is non-blocking(it calls request_firmware_nowait()), and doesn't ensure that the firmware is actually loaded when it returns. We remove the device registration from vpe probe, and move it to a callback provided by the vpe driver to the vpdma library, through vpdma_create(). The ready field in vpdma_data is no longer needed since we always have firmware loaded before the device is registered. A minor problem with this approach is that if the video_register_device fails(which doesn't really happen), the vpe platform device would be registered. however, there won't be any v4l2 device corresponding to it. Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Kamil Debski <k.debski@samsung.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: ti-vpe: retain v4l2_buffer flags for captured buffersArchit Taneja2014-04-071-5/+4Star
| | | | | | | | | | | | The dequed CAPTURE_MPLANE type buffers don't contain the flags that the originally queued OUTPUT_MPLANE type buffers have. This breaks compliance. Copy the source v4l2_buffer flags to the destination v4l2_buffer flags before they are dequed. Reviewed-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
* [media] v4l: ti-vpe: Set correct field parameter for output and capture buffersArchit Taneja2014-04-071-1/+12
| | | | | | | | | | | | | | | | | | | | | The vpe driver wasn't setting the correct field parameter for dequed CAPTURE type buffers for the case where the captured output is progressive. Set the field to V4L2_FIELD_NONE for the completed destination buffers when the captured output is progressive. For OUTPUT type buffers, a queued buffer's field is forced to V4L2_FIELD_NONE if the pixel format(configured through s_fmt for the buffer type V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE specifies) the field type isn't interlaced. If the pixel format specified was V4L2_FIELD_ALTERNATE, and the queued buffer's field isn't V4L2_FIELD_TOP or V4L2_FIELD_BOTTOM, the vb2 buf_prepare op returns an error. This ensures compliance, and that the dequeued output and captured buffers contain the field type that the driver used internally. Signed-off-by: Archit Taneja <archit@ti.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>