summaryrefslogtreecommitdiff
path: root/drivers/staging/vc04_services
AgeCommit message (Collapse)Author
2017-05-15staging: vc04_services: Fix bulk cache maintenancePhil Elwell
vchiq_arm supports transfers less than one page and at arbitrary alignment, using the dma-mapping API to perform its cache maintenance (even though the VPU drives the DMA hardware). Read (DMA_FROM_DEVICE) operations use cache invalidation for speed, falling back to clean+invalidate on partial cache lines, with writes (DMA_TO_DEVICE) using flushes. If a read transfer has ends which aren't page-aligned, performing cache maintenance as if they were whole pages can lead to memory corruption since the partial cache lines at the ends (and any cache lines before or after the transfer area) will be invalidated. This bug was masked until the disabling of the cache flush in flush_dcache_page(). Honouring the requested transfer start- and end-points prevents the corruption. Fixes: cf9caf192988 ("staging: vc04_services: Replace dmac_map_area with dmac_map_sg") Signed-off-by: Phil Elwell <phil@raspberrypi.org> Cc: stable <stable@vger.kernel.org> # 4.10 Reported-by: Stefan Wahren <stefan.wahren@i2se.com> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-18staging: media/platform/bcm2835: remove gstreamer workaroundKevin Wern
Gstreamer's v4l2src reacted poorly to certain outputs from the bcm2835 video driver's ioctl ops function vidioc_enum_framesizes, so a workaround was created that could be activated by user input. This workaround would replace the driver's ioctl ops struct with another, similar struct--only with no function pointed to by vidioc_enum_framesizes. With no response, gstreamer would attempt to continue with some default settings that happened to work better. However, this bug has been fixed in gstreamer since 2014, so we shouldn't include this workaround in the stable version of the driver. Signed-off-by: Kevin Wern <kevin.m.wern@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08staging: vc04_services: add parenthesis to macrosHaim Daniel
vchi_cfg.h: fix checkpatch ERROR: Macros with complex values should be enclosed in parenthesis Signed-off-by: Haim Daniel <haimdaniel@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08staging: bcm2835-audio: remove unnecessary log messagesAishwarya Pant
Remove unnecessary log messages in the driver which are just tracking function entry and exits. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08staging: bcm2835-camera: fix spelling mistake: "elementry" -> "elementary"Colin Ian King
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-27Merge 4.11-rc4 into staging-nextGreg Kroah-Hartman
We need the IIO fixes in here as well to handle merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-21staging: vchiq_arm: Fix MODULE_LICENSEStefan Wahren
Regarding to the header the driver is licensed under BSD and GPL. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-21staging: bcm2835-audio: Add support for simultanous HDMI and Headphone audioMichael Zoran
The firmware for the Raspberry PI already supports simultanous output of audio through both the HDMI and the Headphone jack. The current implementation of ALSA doesn't expose this well to user mode since the firmware audio is represented as a single card. A newer approach is taken here and a virtual card is created for each output(HDMI, Headphones, and Traditional ALSA). The firmware has the concept of channels or streams for which the number to use is passed in the device tree. These streams are allocated to each of the virtual cards. As a side effect of this change, since each output is represented independenly it's now very easy to use PulseAudio to control the priorities of the outputs. Testing: Audacity and VLC were both loaded at the same time. Each application was assigned to a different card. With this change I was able to play different music files at the same time through the HDMI and Headphones jacks and control the audio independently. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-21bcm2835-v4l2: Fix buffer overflow problemDave Stevenson
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-21staging: vc04_services: make BCM_VIDEOCORE tristateArnd Bergmann
Adding the 'bool' symbol brought back a randconfig build bug that I had fixed before: drivers/staging/built-in.o: In function `vchiq_probe': (.text+0x1da30): undefined reference to `rpi_firmware_get' drivers/staging/built-in.o: In function `vchiq_platform_init': (.text+0x27494): undefined reference to `rpi_firmware_property' The problem is that when RASPBERRYPI_FIRMWARE is a loadable module, but BCM2835_VCHIQ can again be built-in. Making BCM_VIDEOCORE itself tristate will make Kconfig honor the dependency correctly. Fixes: 6bbfe4a76158 ("staging: vc04_services: Create new BCM_VIDEOCORE setting for VideoCore services.") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-21staging: vc04_services: fix NULL pointer dereference on pointer 'service'Colin Ian King
Currently, if pservice is null then service is set to NULL and immediately afterwards service is dereferenced causing a null pointer dereference. Fix this by bailing out early of the function with a null return. Detected by CoverityScan, CID#1419681 ("Explicit null dereferenced") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-16staging: vc04_services: Replace typedef with structGargi Sharma
Using typedef for a structure type and upper case struct names is not suggested in Linux kernel coding style guidelines. Hence, occurences of typedefs have been removed and struct names converted to lowercase in the file. Grep was also used to ensure that all occurence of the typedefs have been removed. The module compiles without any warnings or errors. Script 1: @r1@ type T; @@ typedef struct { ... } T; @script:python c1@ T2; T << r1.T; @@ if T[-2:] =="_T": coccinelle.T2 = T[:-2].lower(); print T else: coccinelle.T2=T.lower(); @r2@ type r1.T; identifier c1.T2; @@ -typedef struct + T2 { ... } -T ; @r3@ type r1.T; identifier c1.T2; @@ - T + struct T2 Script 2: @@ typedef VCHIQ_ELEMENT_T; @@ ( - VCHIQ_ELEMENT_T + struct vchiq_element ) Signed-off-by: Gargi Sharma <gs051095@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-16staging: vc04_services: Remove type and function prototypeGargi Sharma
The function prototype is for a function that is not even in the kernel, and hence has been removed. The type VCHIQ_SHARED_MEM_INFO_T is not used anywhere in the kernel as well. Signed-off-by: Gargi Sharma <gs051095@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-16staging: vc04_services: Remove unused functionsJean-Baptiste Abbadie
These four functions are not used and report errors with sparse. Signed-off-by: Jean-Baptiste Abbadie <jb@abbadie.fr> Acked-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14staging: bcm2835-audio: fix memory leak in bcm2835_audio_open_connection()Aishwarya Pant
In bcm2835_audio_open_connection(), if VCHI connection fails or initialisation of VCHI audio instance fails vchi_instance needs to be deallocated otherwise it will cause a memory leak. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14staging: bcm2835-audio: deallocate work when queue_work(...) failsAishwarya Pant
This patch de-allocates work when queue_work(..) fails in the bcm2835-audio work functions Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14staging: bcm2835-audio: use conditional only for error caseAishwarya Pant
* Refactor conditional to check if memory allocation has failed and immediately return (-ENOMEM); if block for success case is removed. * Return the error value -EBUSY when queue_work() fails. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14staging: bcm2835-audio: propagate PTR_ERR value instead of -EPERMAishwarya Pant
It is better to propagate PTR_ERR value instead of a hardcoded value (-EPERM here) Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14staging: bcm2835-audio: replace null with error pointer valueAishwarya Pant
This patch replaces NULL values returned by vc_vchi_audio_init(...) with error pointer values: - Return ERR_PTR(-EINVAL) when too many instances of audio service are initialised - Return ERR_PTR(-ENOMEM) when kzalloc fails - RETURN ERR_PTR(-EPERM) when vchi connections fail to open Similarly, a NULL check where vc_vchi_audio_init(...) is called is replaced by IS_ERR(..) Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-14staging: bcm2835-audio: Replace kmalloc with kzallocAishwarya Pant
Replace kmalloc and memset with kzalloc. Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-12Staging: bcm2835: Fixed style of block commentsDerek Robson
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 Pant
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-12staging: bcm2835-audio: remove anonymous field declarationsAishwarya Pant
Anonymous field declarations are error prone. This patch replaces anonymous declarations with explicit field declarations for typedef SERVICE_CREATION_T in vc_vchi_audio_init(..) Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: vchi: Remove ARM64 from TODO listMichael Zoran
ARM64 for core vchiq which is the core of vc04_services should now be work complete. The driver compiles without any errors or warnings, and works just as well as 32 bit mode. The necessary compatibility wrappers for the 32 bit ioctls have been written and merged. Since no more ARM64 specific changes should be needed, perhaps it's best to remove it from the TODO list. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: use kernel preferred style for handling errorsAishwarya Pant
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 Pant
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 Pant
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: remove depends on ARMMichael Zoran
Since all the arm64 specific issues have been fixed now and the camera is working fine with a arm64 kernel, the depends on ARM can be removed from Kconfig. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-10staging: bcm2835-camera: Fix bogus compiler warnings regarding constantsMichael Zoran
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 ↵Michael Zoran
properties 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 Zoran
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 Zoran
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 Zoran
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 Zoran
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 delayed_buffer to u32Michael Zoran
A delayed buffer field is passed between the firmware and the kernel. This field is never used either so it's safe to change it to a 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_component field to u32Michael Zoran
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-10staging: bcm2835-camera: Create struct mmal_es_format_local to mirror struct ↵Michael Zoran
mmal_es_format The struct struct mmal_es_format is passed between the firmware which has pointers. A local version of mmal_es_format is also used. Luckly, the two versions are always memberwise copied from each other so simply have different structures for the local and msg versions. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vc04_services: Refactor conditionalsNarcisa Ana Maria Vasile
Refactor conditionals to reduce one level of indentation and improve code readability. Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vc04_services: Remove error message on kmalloc() failureNarcisa Ana Maria Vasile
Remove 'Out of memory' message because kmalloc already prints a message in case of error. Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vc04_services: Use ARRAY_SIZE macroGargi Sharma
Use ARRAY_SIZE to calculate the size of an array. The semantic patch used can be found here: https://github.com/coccinelle/coccinellery/blob/master/arraysize/array.cocci Signed-off-by: Gargi Sharma <gs051095@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vchiq_utils: Don't include headers twiceStefan Wahren
There is no need to include types.h and vmalloc.h twice. This issue has been found by make includecheck. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vc04_services: Clean up tests if NULL returned on failuresimran singhal
Some functions like kmalloc/kzalloc return NULL on failure. When NULL represents failure, !x is commonly used. This was done using Coccinelle: @@ expression *e; identifier l1; @@ e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...); ... - e == NULL + !e Signed-off-by: simran singhal <singhalsimran0@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vc04_services: bcm2835-audio: Align with parenthesisSreya Mittal
Fix the checkpatch issue: Alignment should match open parenthesis Signed-off-by: Sreya Mittal <sreyamittal5@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vchiq_arm: Disable ability to dump memory by defaultMichael Zoran
vc04_services has an ioctl interface to dump arbitrary memory to a custom debug log. This is typically only needed by diagnostic tools, and can potentially be a security issue if the devtmpfs node doesn't have adequate permissions set. Since the ability to dump memory still has debugging value, create a new build configuration and disable the feature by default. Signed-off-by: Michael Zoran <mzoran@crowfest.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09staging: vchiq_arm: Add compatibility wrappers for ioctlsMichael Zoran
This patch adds compatibility wrappers for the ioctls exposed by vchiq/vc04_services. The compat ioctls are completely implemented on top of the native ioctls. No existing lines are modified. While the ideal approach would be to cleanup the existing code, this path is simplier and easier to review. While it does have a small runtime performance penality vs seperating the existing code into wrapper+worker functions, the penality is small since only the metadata is copied back onto the 32 bit user mode stack. The on top of approach is the approach used by several existing performance critical subsystems of Linux such as the DRM 3D graphics subsystem. Testing: 1. A 32 bit chroot was created on a RPI 3 and vchiq_test was built for armhf. The usual tests were run such as vchiq_test -f 10 and vchiq_test -p. 2. This patch was copied onto the shipping version of the Linux kernel used for the RPI and that kernel was built for arm64. That kernel was used to boot Raspbian. Many of the builtin features are now functional such as the "hello_pi" examples, and minecraft_pi. 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 ↵Michael Zoran
mmal_msg_header 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-09staging: bcm2835_camera: Convert control_service field of mmal_msg_header to u32Michael Zoran
The camera driver passes messages back and forth between the firmware with requests and replies. One of the fields of the message header called control_service is a pointer so the size changes between 32 bit and 64 bit. Luckly, the field is not interperated by the driver, so it can be changed to a u32 which has a fixed size. 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 Zoran
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-07Staging: media: platform: bcm2835 - style fixDerek Robson
Changed permissions to octal style Found using checkpatch Signed-off-by: Derek Robson <robsonde@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-07staging: bcm2835-audio: remove unused semaphoresAishwarya Pant
This patch removes unused semaphores alsa_stream->buffers_update_sem and alsa_stream->control_sem from struct bcm2835_alsa_stream Signed-off-by: Aishwarya Pant <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>