aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-05-14staging: bcm2835-camera: Replace open-coded idr with a struct idr.Eric Anholt1-104/+31
We just need some integer handles that can map back to our message struct when we're handling a reply, which struct idr is perfect for. v2: Fix error check to look at the right variable. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Remove V4L2/MMAL buffer remappingDave Stevenson1-84/+25
The MMAL and V4L2 buffers had been disassociated, and linked on demand. Seeing as both are finite and low in number, and we now have the same number of each, link them for the duration. This removes the complexity of maintaining lists as the struct mmal_buffer context comes back from the VPU, so we can directly link back to the relevant V4L2 buffer. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Match MMAL buffer count to V4L2.Dave Stevenson1-20/+1
For historical reasons, the number of buffers passed to the VPU over MMAL did not match that passed from V4L2. That is a silly situation as the driver has to duplicate serialisation and other functions that have already been implemented in V4L2/videobuf2. As we had more V4L2 buffers than MMAL ones, the MMAL buffer headers were returned to the VPU immediately on being filled, which is now invalid. Match the number of buffers notified in queue_setup with that used in MMAL. Return buffers only when we get them from V4L2. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Remove bulk_mutex as it is not requiredDave Stevenson1-47/+1
There is no requirement to serialise bulk transfers as that is all done in VCHI, and if a second MMAL_MSG_TYPE_BUFFER_TO_HOST happened before the VCHI_CALLBACK_BULK_RECEIVED, then the service_callback thread is deadlocked. Remove the bulk_mutex so that multiple receives can be scheduled at a time. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-11staging: bcm2835-camera: Allocate context once per bufferDave Stevenson1-10/+28
The struct mmal_msg_context was being allocated for every message being sent to the VPU, and freed when it came back. Whilst that is required behaviour for some messages (mainly the synchronous ones), it is wasteful for the video buffers that make up the majority of the traffic. Add to the buffer_init/cleanup hooks that it allocates/frees the msg_context required. v2: changes by anholt from the downstream tree: clean up indentation, pass an error value through, forward-declare the struct so we have less void * Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: vc04_services: bcm2835-camera: remove redundant license textGreg Kroah-Hartman1-4/+0
Now that the SPDX tag is in all drivers/staging/vc04_services/bcm2835-camera/ files, that identifies the license in a specific and legally-defined manner. So the extra GPL text wording can be removed as it is no longer needed at all. This is done on a quest to remove the 700+ different ways that files in the kernel describe the GPL license text. And there's unneeded stuff like the address (sometimes incorrect) for the FSF which is never needed. No copyright headers or other non-license-description text was removed. Cc: Eric Anholt <eric@anholt.net> Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Ray Jui <rjui@broadcom.com> Cc: Scott Branden <sbranden@broadcom.com> Cc: <bcm-kernel-feedback-list@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-01-15staging: vc04_services: bcm2835-camera: add SPDX identifiersGreg Kroah-Hartman1-0/+1
It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Fix up the bcm2835-camera driver to have a proper SPDX identifier, based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This work is based on a script and data from Thomas Gleixner, Philippe Ombredanne, and Kate Stewart. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Kate Stewart <kstewart@linuxfoundation.org> Cc: Philippe Ombredanne <pombredanne@nexb.com> Cc: Eric Anholt <eric@anholt.net> Cc: Stefan Wahren <stefan.wahren@i2se.com> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Ray Jui <rjui@broadcom.com> Cc: Scott Branden <sbranden@broadcom.com> Cc: <bcm-kernel-feedback-list@broadcom.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06staging: vc04_services: Use __func__Genki Sky1-2/+2
This was found using checkpatch.pl's EMBEDDED_FUNCTION_NAME warning. It is easier to be consistent and always use __func__ instead of having to remember to update any hardcoded references to the original name. Signed-off-by: Genki Sky <sky@genki.is> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-06staging: vc04_services: Unsplit user-visible stringsGenki Sky1-2/+1
This was found using checkpatch.pl's SPLIT_STRING warning. While joining these strings makes for long lines, the kernel codebase consistently does it this way to make user-visible strings easier to grep for. Signed-off-by: Genki Sky <sky@genki.is> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-03staging: bcm2835-camera: pr_err() strings should end with newlinesArvind Yadav1-1/+1
pr_err() messages should end with a new-line to avoid other messages being concatenated. Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08staging: bcm2835-camera: fix spelling mistake: "elementry" -> "elementary"Colin Ian King1-3/+3
trivial fix to spelling mistake in various comments and pr_debug messages Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-21bcm2835-v4l2: Fix buffer overflow problemDave Stevenson1-1/+6
https://github.com/raspberrypi/linux/issues/1447 port_parameter_get() failed to account for the header (u32 id and u32 size) in the size before memcpying the response into the response buffer, so overrunning the provided buffer by 8 bytes. Account for those bytes, and also a belt-and-braces check to ensure we never copy more than *value_size bytes into value. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org> Signed-off-by: Michael Zoran <mzoran@crowfest.net> Tested-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12Staging: bcm2835: Fixed style of block commentsDerek Robson1-1/+2
Fixed style of block comments across whole driver Found using checkpatch Signed-off-by: Derek Robson <robsonde@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12staging: bcm2835-camera: remove anonymous field declarationsAishwarya Pant1-10/+10
Anonymous field declarations are error prone. This patch replaces anonymous declarations with explicit field declarations for typedef SERVICE_CREATION_T in vchiq_mmal_init(..) Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: use kernel preferred style for handling errorsAishwarya Pant1-6/+6
This patch replaces NULL error values with error pointer values. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: replace kmalloc with kzallocAishwarya Pant1-5/+3
This patch replaces kmalloc and memset with kzalloc Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: add check to avoid null pointer dereferenceAishwarya Pant1-2/+8
This patch adds checks after memory allocation to avoid possible null pointer dereferences. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Fix bogus compiler warnings regarding constantsMichael Zoran1-1/+2
In debug logging code, the compiler is warning about imposible situations and size of constants not matching the format specifier. This change fixes all three instances of this. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Fix buffer overflow calculation on query of camera propertiesMichael Zoran1-1/+1
The code that queries properties on the camera has a check for buffer overruns if the firmware sends too much data. This check is incorrect, and during testing I was seeing stack corruption. I believe this error can actually happen in normal use, just for some reason it doesn't appear on 32 bit as often. So perhaps it's best for the check to be fixed. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Convert spinlock to mutex in handle mapping codeMichael Zoran1-12/+11
The handle mapping code that converts context pointers to handles uses a spinlock. Since the btree implementation can sleep while allocating memory, turning on several kernel debugging options will result in errors in the log. Since this code path is never called in atomic context, perhaps it's better to just use a mutex. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Convert struct mmal_buffer_header info fields to u32Michael Zoran1-1/+2
The struct mmal_buffer_header has multiple fields used for informational and debugging purposes. These are safe to convert to u32. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Convert struct mmal_port info fields to u32Michael Zoran1-1/+1
The struct mmal_port has a few informational fields. Convert these to u32. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Convert client_context field to a 32 bit handleMichael Zoran1-2/+10
The client_context field is passed around which is really just a pointer to a msg_context. A lookup table mechanism for msg_context was added previously, so convert this field to a handle as well. The firmware never interperates the client_context, just passed it back. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Convert client_component field to u32Michael Zoran1-2/+2
In the messages passed back and forth between the camera and the firmware, a client_component field is passed. This is a pointer to a structure that represents part of the camera. Luckly, it's only used for debug logging, so simply convert it to a u32. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: bcm2835_camera: Use a mapping table for context field of mmal_msg_headerMichael Zoran1-22/+154
The camera driver passes messages back and forth between the firmware with requests and replies. One of the fields of the message header called context is a pointer so the size changes between 32 bit and 64 bit. The context field is used to pair reply messages from the firmware with request messages from the kernel. The simple solution would be to use the padding field for the upper 32 bits of pointers, but this would rely on the firmware always copying the pad field. So instead handles are generated that are 32 bit numbers and a mapping stored in a btree as implemented by the btree library in the kernel lib directory. The mapping pairs the handle with the pointer to the actual data. The btree library was chosen since it's very easy to use and red black trees would be overkill. The camera driver also now forces in the btree library if the camera is included in the build. The btree library is a hidden configuration option. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-08staging: bcm2835-camera: Remove explicit cache flush operationsMichael Zoran1-4/+0
The camera code has an explicit cache flush operation which is not portable. Now that vc04_services is using portable DMA APIs that already do the cache flushing, explicit flushes should no longer be needed. The one call to __cpuc_flush_dcache_area has been removed. Testing: The offical V2 camera for the RPI was tested on a RPI 3 running in 32 bit mode(armhf). The cheese application and ffmpeg was used to view and stream video from the camera. Nothing new seems to be broken without the cache flushing. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06staging: vc04_services: bcm2835-camera: Simplify NULL comparisonsAishwarya Pant1-5/+5
Remove instances of explicit NULL comparisons in bcm2835-camera driver for code compaction. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-06staging: bcm2835-camera: Move driver under vc04_servicesMichael Zoran1-0/+1916
The bcm2835-camera driver is part of v04_services, so it makes sense for it to be located under vc04_services to make configuration clearer. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>