staging: bcm2835-camera probing and cleanup
Subsystems (3)
cover staging: bcm2835-camera probing and cleanup
I'm going to try to get Dave Stevenson's new zero-copy v4l2 M2M codec driver merged to staging (my primary motivation for getting vchi merged in the first place!), and this series makes the camera driver probe successfully (an important first step!) and brings in some of his cleanup changes. Also a couple of compiler warning fixes, for my own sanity.
Apologies to those who saw the first two patches last night. My git-send-email-for-staging script was missing gregkh.
Dave Stevenson (10):
staging: bcm2835-camera: Skip ISP pass to eliminate padding.
staging: bcm2835-camera: Allocate context once per buffer
staging: bcm2835-camera: Remove bulk_mutex as it is not required
staging: bcm2835-camera: Match MMAL buffer count to V4L2.
staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping
staging: bcm2835-camera: Add multiple include protection
staging: bcm2835-camera: Move struct vchiq_mmal_rect
staging: bcm2835-camera: Replace BUG_ON with return error
staging: bcm2835-camera: Fix comment typos.
staging: bcm2835-camera: Fix indentation of tables
Eric Anholt (5):
staging/vc04_services: Register a platform device for the camera
driver.
staging/bcm2835-camera: Set ourselves up as a platform driver.
staging: bcm2835-camera: Fix warnings about string ops on v4l2 uapi.
staging: bcm2835: Remove dead code related to framerate.
staging: bcm2835: Fix mmal_port_parameter_get() signed/unsigned
warnings.
.../staging/vc04_services/bcm2835-camera/TODO | 11 - .../bcm2835-camera/bcm2835-camera.c | 396 ++++++++++-------- .../bcm2835-camera/mmal-common.h | 7 + .../bcm2835-camera/mmal-msg-port.h | 2 +- .../bcm2835-camera/mmal-parameters.h | 13 + .../vc04_services/bcm2835-camera/mmal-vchiq.c | 210 +++------- .../vc04_services/bcm2835-camera/mmal-vchiq.h | 15 +- .../interface/vchiq_arm/vchiq_arm.c | 6 + 8 files changed, 301 insertions(+), 359 deletions(-)
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 1/15 staging/vc04_services: Register a platform device for the camera driver.
We had the camera driver set up in a module_init function, but that meant that the camera driver would fail to load if it was initialized before VCHI. By attaching to this platform_device, it can get a defined load order.
--- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +6 -0
@@ -168,6 +168,7 @@ static VCHIQ_STATE_T g_state;static struct class *vchiq_class;static struct device *vchiq_dev;static DEFINE_SPINLOCK (msg_queue_spinlock); +static struct platform_device *bcm2835_camera;static const char *const ioctl_names[] = {"CONNECT" ,
@@ -3638,6 +3639,10 @@ static int vchiq_probe(struct platform_device *pdev)VCHIQ_VERSION ,VCHIQ_VERSION_MIN , MAJOR(vchiq_devid), MINOR(vchiq_devid)); + bcm2835_camera =platform_device_register_data (&pdev->dev, +"bcm2835-camera" ,-1 , +NULL ,0 ); +return 0 ; failed_debugfs_init:
@@ -3655,6 +3660,7 @@ static int vchiq_probe(struct platform_device *pdev)static int vchiq_remove (struct platform_device *pdev) { +platform_device_unregister (bcm2835_camera);vchiq_debugfs_deinit ();device_destroy (vchiq_class, vchiq_devid);class_destroy (vchiq_class);
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 2/15 staging/bcm2835-camera: Set ourselves up as a platform driver.
In reply to Eric AnholtThis allows bcm2835-camera to automatically probe after VCHI has loaded, rather than only successfully probing if the arbitrary probe order chooses us after VCHI.
--- .../staging/vc04_services/bcm2835-camera/TODO | 11 ----------- .../bcm2835-camera/bcm2835-camera.c | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 15 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/TODO +0 -11
@@ -21,14 +21,3 @@ less copy it needed to do. The bulk_receive() does some manual cache flushing that are 32-bit ARM only, which we should convert to proper cross-platform APIs. -4) Convert to be a platform driver. - -Right now when the module probes, it tries to initialize VCHI and -errors out if it wasn't ready yet. If bcm2835-v4l2 was built in, then -VCHI generally isn't ready because it depends on both the firmware and -mailbox drivers having already loaded. - -We should have VCHI create a platform device once it's initialized, -and have this driver bind to it, so that we automatically load the -v4l2 module after VCHI loads. -
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +14 -4
@@ -23,6 +23,7 @@#include <media/v4l2-event.h> #include <media/v4l2-common.h> #include <linux/delay.h> +#include <linux/platform_device.h> #include "mmal-common.h" #include "mmal-encodings.h"
@@ -1803,7 +1804,7 @@ static struct v4l2_format default_v4l2_format = { .fmt.pix.sizeimage = 1024 * 768, }; -static int __init bm2835_mmal_init (void ) +static int __init bcm2835_mmal_probe (struct platform_device *pdev) {int ret;struct bm2835_mmal_dev *dev;
@@ -1923,7 +1924,7 @@ static int __init bm2835_mmal_init(void)return ret; } -static void __exit bm2835_mmal_exit(void) +static int bcm2835_mmal_remove (struct platform_device *pdev) {int camera;struct vchiq_mmal_instance *instance = gdev[0 ]->instance;
@@ -1933,7 +1934,16 @@ static void __exit bm2835_mmal_exit(void) gdev[camera] =NULL ; }vchiq_mmal_finalise (instance); + +return 0 ; } -module_init (bm2835_mmal_init); -module_exit (bm2835_mmal_exit); +static struct platform_driver bcm2835_camera_driver = { + .probe = bcm2835_mmal_probe, + .remove = bcm2835_mmal_remove, + .driver = { + .name ="bcm2835-camera" , + }, +}; + +module_platform_driver (bcm2835_camera_driver)
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 3/15 staging: bcm2835-camera: Skip ISP pass to eliminate padding.
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
Interleaved RGB and single plane YUV formats can be delivered by the GPU without the secondary step of removing padding, as the bytesperline field can be set appropriately.
Planar YUV needs the GPU to still remove padding, as there is no way to report that there is padding between the planes (ie on the height). The multi-planar formats are NOT applicable, as there is no easy way to make them contiguous in memory (ie one large allocation that gets broken up). The whole task is passed across to videobuf2 which has no notion of that requirement.
v2: Changes by anholt from the downstream driver: Flag two more planar
formats as needing padding removal, and remove broken userspace workaround.
--- .../bcm2835-camera/bcm2835-camera.c | 44 ++++++++++++++----- .../bcm2835-camera/mmal-common.h | 3 ++ 2 files changed, 35 insertions(+), 12 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +32 -12
@@ -86,6 +86,7 @@ static struct mmal_fmt formats[] = { .depth = 12, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 1, + .remove_padding = 1, }, { .name = "4:2:2, packed, YUYV",
@@ -95,6 +96,7 @@ static struct mmal_fmt formats[] = { .depth = 16, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 2, + .remove_padding = 0, }, { .name = "RGB24 (LE)",
@@ -104,6 +106,7 @@ static struct mmal_fmt formats[] = { .depth = 24, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 3, + .remove_padding = 0, }, { .name = "JPEG",
@@ -113,6 +116,7 @@ static struct mmal_fmt formats[] = { .depth = 8, .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE, .ybbp = 0, + .remove_padding = 0, }, { .name = "H264",
@@ -122,6 +126,7 @@ static struct mmal_fmt formats[] = { .depth = 8, .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE, .ybbp = 0, + .remove_padding = 0, }, { .name = "MJPEG",
@@ -131,6 +136,7 @@ static struct mmal_fmt formats[] = { .depth = 8, .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE, .ybbp = 0, + .remove_padding = 0, }, { .name = "4:2:2, packed, YVYU",
@@ -140,6 +146,7 @@ static struct mmal_fmt formats[] = { .depth = 16, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 2, + .remove_padding = 0, }, { .name = "4:2:2, packed, VYUY",
@@ -149,6 +156,7 @@ static struct mmal_fmt formats[] = { .depth = 16, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 2, + .remove_padding = 0, }, { .name = "4:2:2, packed, UYVY",
@@ -158,6 +166,7 @@ static struct mmal_fmt formats[] = { .depth = 16, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 2, + .remove_padding = 0, }, { .name = "4:2:0, planar, NV12",
@@ -167,6 +176,7 @@ static struct mmal_fmt formats[] = { .depth = 12, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 1, + .remove_padding = 1, }, { .name = "RGB24 (BE)",
@@ -176,6 +186,7 @@ static struct mmal_fmt formats[] = { .depth = 24, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 3, + .remove_padding = 0, }, { .name = "4:2:0, planar, YVU",
@@ -185,6 +196,7 @@ static struct mmal_fmt formats[] = { .depth = 12, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 1, + .remove_padding = 1, }, { .name = "4:2:0, planar, NV21",
@@ -194,6 +206,7 @@ static struct mmal_fmt formats[] = { .depth = 12, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 1, + .remove_padding = 1, }, { .name = "RGB32 (BE)",
@@ -203,6 +216,7 @@ static struct mmal_fmt formats[] = { .depth = 32, .mmal_component = MMAL_COMPONENT_CAMERA, .ybbp = 4, + .remove_padding = 0, }, };
@@ -929,9 +943,19 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, &f->fmt.pix.height,MIN_HEIGHT , dev->max_height, 1, 0); f->fmt.pix.bytesperline = f->fmt.pix.width * mfmt->ybbp; +if (!mfmt->remove_padding) { +int align_mask = ((32 * mfmt->depth) >>3 ) -1 ; +/* GPU isn't removing padding, so stride is aligned to 32 */ + f->fmt.pix.bytesperline = + (f->fmt.pix.bytesperline + align_mask) & ~align_mask; +v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, +"Not removing padding, so bytes/line = %d, " +"(align_mask %d)\n" , + f->fmt.pix.bytesperline, align_mask); + }/* Image buffer has to be padded to allow for alignment, even though -* we then remove that padding before delivering the buffer. +* we sometimes then remove that padding before delivering the buffer. */ f->fmt.pix.sizeimage = ((f->fmt.pix.height +15 ) & ~15 ) * (((f->fmt.pix.width +31 ) & ~31 ) * mfmt->depth) >>3 ;
@@ -964,6 +988,7 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev,struct vchiq_mmal_port *port =NULL , *camera_port =NULL ;struct vchiq_mmal_component *encode_component =NULL ;struct mmal_fmt *mfmt =get_format (f); +u32 remove_padding;BUG_ON (!mfmt);
@@ -1032,6 +1057,12 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, camera_port->format.encoding =MMAL_ENCODING_RGB24 ; } + remove_padding = mfmt->remove_padding; +vchiq_mmal_port_parameter_set (dev->instance, + camera_port, +MMAL_PARAMETER_NO_IMAGE_PADDING , + &remove_padding,sizeof (remove_padding)); + camera_port->format.encoding_variant =0 ; camera_port->es.video.width = f->fmt.pix.width; camera_port->es.video.height = f->fmt.pix.height;
@@ -1509,7 +1540,6 @@ static int __init mmal_init(struct bm2835_mmal_dev *dev) {int ret;struct mmal_es_format_local *format; -u32 bool_true =1 ;u32 supported_encodings[MAX_SUPPORTED_ENCODINGS ];int param_size;struct vchiq_mmal_component *camera;
@@ -1593,11 +1623,6 @@ static int __init mmal_init(struct bm2835_mmal_dev *dev) format->es->video.frame_rate.num =0 ;/* Rely on fps_range */ format->es->video.frame_rate.den =1 ; -vchiq_mmal_port_parameter_set (dev->instance, - &camera->output[MMAL_CAMERA_PORT_VIDEO ], -MMAL_PARAMETER_NO_IMAGE_PADDING , - &bool_true,sizeof (bool_true)); - format = &camera->output[MMAL_CAMERA_PORT_CAPTURE ].format; format->encoding =MMAL_ENCODING_OPAQUE ;
@@ -1619,11 +1644,6 @@ static int __init mmal_init(struct bm2835_mmal_dev *dev) dev->capture.enc_profile =V4L2_MPEG_VIDEO_H264_PROFILE_HIGH ; dev->capture.enc_level =V4L2_MPEG_VIDEO_H264_LEVEL_4_0 ; -vchiq_mmal_port_parameter_set (dev->instance, - &camera->output[MMAL_CAMERA_PORT_CAPTURE ], -MMAL_PARAMETER_NO_IMAGE_PADDING , - &bool_true,sizeof (bool_true)); -/* get the preview component ready */ ret = vchiq_mmal_component_init( dev->instance, "ril.video_render",
drivers/staging/vc04_services/bcm2835-camera/mmal-common.h +3 -0
@@ -28,6 +28,9 @@ struct mmal_fmt {int depth;u32 mmal_component;/* MMAL component index to be used to encode */ u32 ybbp;/* depth of first Y plane for planar formats */ +bool remove_padding;/* Does the GPU have to remove padding, +* or can we do hide padding via bytesperline. +*/ };/* buffer for one video frame */
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 4/15 staging: bcm2835-camera: Allocate context once per buffer
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
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 *
--- .../bcm2835-camera/bcm2835-camera.c | 30 +++++++++++++-- .../bcm2835-camera/mmal-common.h | 4 ++ .../vc04_services/bcm2835-camera/mmal-vchiq.c | 38 ++++++++++++++----- .../vc04_services/bcm2835-camera/mmal-vchiq.h | 3 ++ 4 files changed, 62 insertions(+), 13 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +27 -3
@@ -278,6 +278,20 @@ static int queue_setup(struct vb2_queue *vq,return 0 ; } +static int buffer_init (struct vb2_buffer *vb) +{ +struct bm2835_mmal_dev *dev =vb2_get_drv_priv (vb->vb2_queue); +struct vb2_v4l2_buffer *vb2 =to_vb2_v4l2_buffer (vb); + struct mmal_buffer *buf = container_of(vb2, struct mmal_buffer, vb); + +v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"%s: dev:%p, vb %p\n" , + __func__, dev, vb); + buf->buffer =vb2_plane_vaddr (&buf->vb.vb2_buf,0 ); + buf->buffer_size =vb2_plane_size (&buf->vb.vb2_buf,0 ); + +return mmal_vchi_buffer_init (dev->instance, buf); +} +static int buffer_prepare (struct vb2_buffer *vb) {struct bm2835_mmal_dev *dev =vb2_get_drv_priv (vb->vb2_queue);
@@ -300,6 +314,17 @@ static int buffer_prepare(struct vb2_buffer *vb)return 0 ; } +static void buffer_cleanup (struct vb2_buffer *vb) +{ +struct bm2835_mmal_dev *dev =vb2_get_drv_priv (vb->vb2_queue); +struct vb2_v4l2_buffer *vb2 =to_vb2_v4l2_buffer (vb); + struct mmal_buffer *buf = container_of(vb2, struct mmal_buffer, vb); + +v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"%s: dev:%p, vb %p\n" , + __func__, dev, vb); +mmal_vchi_buffer_cleanup (buf); +} +static inline bool is_capturing (struct bm2835_mmal_dev *dev) { return dev->capture.camera_port ==
@@ -467,9 +492,6 @@ static void buffer_queue(struct vb2_buffer *vb)v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"%s: dev:%p buf:%p\n" , __func__, dev, buf); - buf->buffer =vb2_plane_vaddr (&buf->vb.vb2_buf,0 ); - buf->buffer_size =vb2_plane_size (&buf->vb.vb2_buf,0 ); - ret =vchiq_mmal_submit_buffer (dev->instance, dev->capture.port, buf);if (ret <0 ) v4l2_err(&dev->v4l2_dev, "%s: error submitting buffer\n",
@@ -632,7 +654,9 @@ static void bm2835_mmal_unlock(struct vb2_queue *vq)static const struct vb2_ops bm2835_mmal_video_qops = { .queue_setup = queue_setup, + .buf_init = buffer_init, .buf_prepare = buffer_prepare, + .buf_cleanup = buffer_cleanup, .buf_queue = buffer_queue, .start_streaming = start_streaming, .stop_streaming = stop_streaming,
drivers/staging/vc04_services/bcm2835-camera/mmal-common.h +4 -0
@@ -19,6 +19,8 @@/** Special value signalling that time is not known */ #define MMAL_TIME_UNKNOWN (1LL<<63) +struct mmal_msg_context ; +/* mapping between v4l and mmal video modes */ struct mmal_fmt {char *name;
@@ -43,6 +45,8 @@ struct mmal_buffer {void *buffer;/* buffer pointer */ unsigned long buffer_size;/* size of allocated buffer */ + +struct mmal_msg_context *msg_context; };/* */
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +28 -10
@@ -321,8 +321,6 @@ static void buffer_work_cb(struct work_struct *work) msg_context->u.bulk.dts, msg_context->u.bulk.pts); -/* release message context */ -release_msg_context (msg_context); }/* enqueue a bulk receive for a given message context */
@@ -503,11 +501,13 @@ buffer_from_host(struct vchiq_mmal_instance *instance,return -EINTR ;/* get context */ - msg_context =get_msg_context (instance); -if (IS_ERR (msg_context)) { - ret =PTR_ERR (msg_context); +if (!buf->msg_context) { +pr_err ("%s: msg_context not allocated, buf %p\n" , __func__, + buf); + ret = -EINVAL ; goto unlock; } + msg_context = buf->msg_context;/* store bulk message context for when data arrives */ msg_context->u.bulk.instance = instance;
@@ -557,11 +557,6 @@ buffer_from_host(struct vchiq_mmal_instance *instance,sizeof (struct mmal_msg_header ) + sizeof(m.u.buffer_from_host)); -if (ret !=0 ) { -release_msg_context (msg_context); -/* todo: is this correct error value? */ - } -vchi_service_release (instance->handle); unlock:
@@ -1775,6 +1770,29 @@ int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,return 0 ; } +int mmal_vchi_buffer_init (struct vchiq_mmal_instance *instance, +struct mmal_buffer *buf) +{ +struct mmal_msg_context *msg_context =get_msg_context (instance); + +if (IS_ERR (msg_context)) +return (PTR_ERR (msg_context)); + + buf->msg_context = msg_context; +return 0 ; +} + +int mmal_vchi_buffer_cleanup (struct mmal_buffer *buf) +{ +struct mmal_msg_context *msg_context = buf->msg_context; + +if (msg_context) +release_msg_context (msg_context); + buf->msg_context =NULL ; + +return 0 ; +} +/* Initialise a mmal component and its ports * */
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +3 -0
@@ -168,4 +168,7 @@ int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,struct vchiq_mmal_port *port, struct mmal_buffer *buf); +int mmal_vchi_buffer_init (struct vchiq_mmal_instance *instance, +struct mmal_buffer *buf); +int mmal_vchi_buffer_cleanup (struct mmal_buffer *buf);#endif /* MMAL_VCHIQ_H */
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 5/15 staging: bcm2835-camera: Remove bulk_mutex as it is not required
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
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.
--- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 48 +------------------ 1 file changed, 1 insertion(+), 47 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +1 -47
@@ -162,9 +162,6 @@ struct vchiq_mmal_instance {/* ensure serialised access to service */ struct mutex vchiq_mutex; -/* ensure serialised access to bulk operations */ -struct mutex bulk_mutex; -/* vmalloc page to receive scratch bulk xfers into */ void *bulk_scratch;
@@ -332,13 +329,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance,unsigned long flags =0 ;int ret; -/* bulk mutex stops other bulk operations while we have a -* receive in progress - released in callback -*/ - ret =mutex_lock_interruptible (&instance->bulk_mutex); -if (ret !=0 ) -return ret; - rd_len = msg->u.buffer_from_host.buffer_header.length;/* take buffer from queue */
@@ -357,8 +347,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance,* waiting bulk receive? */ -mutex_unlock (&instance->bulk_mutex); -return -EINVAL ; }
@@ -399,11 +387,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance,vchi_service_release (instance->handle); -if (ret !=0 ) { -/* callback will not be clearing the mutex */ -mutex_unlock (&instance->bulk_mutex); - } -return ret; }
@@ -413,13 +396,6 @@ static int dummy_bulk_receive(struct vchiq_mmal_instance *instance, {int ret; -/* bulk mutex stops other bulk operations while we have a -* receive in progress - released in callback -*/ - ret =mutex_lock_interruptible (&instance->bulk_mutex); -if (ret !=0 ) -return ret; -/* zero length indicates this was a dummy transfer */ msg_context->u.bulk.buffer_used =0 ;
@@ -435,11 +411,6 @@ static int dummy_bulk_receive(struct vchiq_mmal_instance *instance,vchi_service_release (instance->handle); -if (ret !=0 ) { -/* callback will not be clearing the mutex */ -mutex_unlock (&instance->bulk_mutex); - } -return ret; }
@@ -494,18 +465,11 @@ buffer_from_host(struct vchiq_mmal_instance *instance,pr_debug ("instance:%p buffer:%p\n" , instance->handle, buf); -/* bulk mutex stops other bulk operations while we -* have a receive in progress -*/ -if (mutex_lock_interruptible (&instance->bulk_mutex)) -return -EINTR ; -/* get context */ if (!buf->msg_context) {pr_err ("%s: msg_context not allocated, buf %p\n" , __func__, buf); - ret = -EINVAL ; - goto unlock; +return -EINVAL ; } msg_context = buf->msg_context;
@@ -559,9 +523,6 @@ buffer_from_host(struct vchiq_mmal_instance *instance,vchi_service_release (instance->handle); -unlock: -mutex_unlock (&instance->bulk_mutex); -return ret; }
@@ -685,9 +646,6 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,static void bulk_receive_cb (struct vchiq_mmal_instance *instance,struct mmal_msg_context *msg_context) { -/* bulk receive operation complete */ -mutex_unlock (&msg_context->u.bulk.instance->bulk_mutex); -/* replace the buffer header */ port_buffer_from_host (msg_context->u.bulk.instance, msg_context->u.bulk.port);
@@ -703,9 +661,6 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, {pr_err ("%s: bulk ABORTED msg_context:%p\n" , __func__, msg_context); -/* bulk receive operation complete */ -mutex_unlock (&msg_context->u.bulk.instance->bulk_mutex); -/* replace the buffer header */ port_buffer_from_host (msg_context->u.bulk.instance, msg_context->u.bulk.port);
@@ -2042,7 +1997,6 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)return -ENOMEM ;mutex_init (&instance->vchiq_mutex); -mutex_init (&instance->bulk_mutex); instance->bulk_scratch =vmalloc (PAGE_SIZE );
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 6/15 staging: bcm2835-camera: Match MMAL buffer count to V4L2.
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
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.
--- .../bcm2835-camera/bcm2835-camera.c | 6 ++++-- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 21 +------------------ .../vc04_services/bcm2835-camera/mmal-vchiq.h | 4 ---- 3 files changed, 5 insertions(+), 26 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +4 -2
@@ -260,8 +260,10 @@ static int queue_setup(struct vb2_queue *vq,return -EINVAL ; } -if (*nbuffers < (dev->capture.port->current_buffer.num +2 )) - *nbuffers = (dev->capture.port->current_buffer.num +2 ); +if (*nbuffers < dev->capture.port->minimum_buffer.num) + *nbuffers = dev->capture.port->minimum_buffer.num; + + dev->capture.port->current_buffer.num = *nbuffers; *nplanes =1 ;
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +1 -20
@@ -545,7 +545,6 @@ static int port_buffer_from_host(struct vchiq_mmal_instance *instance,/* peek buffer from queue */ spin_lock_irqsave (&port->slock, flags);if (list_empty (&port->buffers)) { - port->buffer_underflow++;spin_unlock_irqrestore (&port->slock, flags);return -ENOSPC ; }
@@ -636,9 +635,6 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance, msg->u.buffer_from_host.payload_in_message; } -/* replace the buffer header */ -port_buffer_from_host (instance, msg_context->u.bulk.port); -/* schedule the port callback */ schedule_work (&msg_context->u.bulk.work); }
@@ -646,10 +642,6 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance,static void bulk_receive_cb (struct vchiq_mmal_instance *instance,struct mmal_msg_context *msg_context) { -/* replace the buffer header */ -port_buffer_from_host (msg_context->u.bulk.instance, - msg_context->u.bulk.port); - msg_context->u.bulk.status =0 ;/* schedule the port callback */
@@ -661,10 +653,6 @@ static void bulk_abort_cb(struct vchiq_mmal_instance *instance, {pr_err ("%s: bulk ABORTED msg_context:%p\n" , __func__, msg_context); -/* replace the buffer header */ -port_buffer_from_host (msg_context->u.bulk.instance, - msg_context->u.bulk.port); - msg_context->u.bulk.status = -EINTR ;schedule_work (&msg_context->u.bulk.work);
@@ -1713,14 +1701,7 @@ int vchiq_mmal_submit_buffer(struct vchiq_mmal_instance *instance,list_add_tail (&buffer->list, &port->buffers);spin_unlock_irqrestore (&port->slock, flags); -/* the port previously underflowed because it was missing a -* mmal_buffer which has just been added, submit that buffer -* to the mmal service. -*/ -if (port->buffer_underflow) { -port_buffer_from_host (instance, port); - port->buffer_underflow--; - } +port_buffer_from_host (instance, port);return 0 ; }
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +0 -4
@@ -79,10 +79,6 @@ struct vchiq_mmal_port {struct list_head buffers;/* lock to serialise adding and removing buffers from list */ spinlock_t slock; -/* count of how many buffer header refils have failed because -* there was no buffer to satisfy them -*/ -int buffer_underflow;/* callback on buffer completion */ vchiq_mmal_buffer_cb buffer_cb;/* callback context */
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 7/15 staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
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.
--- .../bcm2835-camera/bcm2835-camera.c | 7 +- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 109 ++++-------------- 2 files changed, 29 insertions(+), 87 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +4 -3
@@ -299,8 +299,8 @@ static int buffer_prepare(struct vb2_buffer *vb)struct bm2835_mmal_dev *dev =vb2_get_drv_priv (vb->vb2_queue);unsigned long size; -v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"%s: dev:%p\n" , - __func__, dev); +v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"%s: dev:%p, vb %p\n" , + __func__, dev, vb);BUG_ON (!dev->capture.port);BUG_ON (!dev->capture.fmt);
@@ -492,7 +492,8 @@ static void buffer_queue(struct vb2_buffer *vb)int ret;v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev, -"%s: dev:%p buf:%p\n" , __func__, dev, buf); +"%s: dev:%p buf:%p, idx %u\n" , + __func__, dev, buf, vb2->vb2_buf.index); ret =vchiq_mmal_submit_buffer (dev->instance, dev->capture.port, buf);if (ret <0 )
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +25 -84
180 lines not on this page · raw message
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 8/15 staging: bcm2835-camera: Add multiple include protection
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
mmal-parameters.h didn't have the normal
...
protection to stop it being included multiple times. Add it.
--- .../staging/vc04_services/bcm2835-camera/mmal-parameters.h | 5 +++++ 1 file changed, 5 insertions(+)
drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h +5 -0
@@ -18,6 +18,9 @@* @{ */ +#ifndef __MMAL_PARAMETERS_H +#define __MMAL_PARAMETERS_H +/** Common parameter ID group, used with many types of component. */ #define MMAL_PARAMETER_GROUP_COMMON (0<<16)/** Camera-specific parameter ID group. */
@@ -682,3 +685,5 @@ struct mmal_parameter_camera_info_t {struct mmal_parameter_camera_info_flash_t flashes[MMAL_PARAMETER_CAMERA_INFO_MAX_FLASHES]; }; + +#endif
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 9/15 staging: bcm2835-camera: Move struct vchiq_mmal_rect
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
struct vchiq_mmal_rect is only referenced from mmal-parameters.h, yet was defined in mmal-vchiq.h.
Move it to avoid having to include multiple headers for no reason.
--- .../vc04_services/bcm2835-camera/mmal-parameters.h | 8 ++++++++ drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h +8 -0
@@ -564,6 +564,14 @@ enum mmal_parameter_displayset { MMAL_DISPLAY_SET_ALPHA = 0x400, }; +/* rectangle, used lots so it gets its own struct */ +struct vchiq_mmal_rect { +s32 x; +s32 y; +s32 width; +s32 height; +}; +struct mmal_parameter_displayregion {/** Bitfield that indicates which fields are set and should be * used. All other fields will maintain their current value.
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +0 -8
@@ -32,14 +32,6 @@ enum vchiq_mmal_es_type {MMAL_ES_TYPE_SUBPICTURE /**< Sub-picture elementary stream */ }; -/* rectangle, used lots so it gets its own struct */ -struct vchiq_mmal_rect { -s32 x; -s32 y; -s32 width; -s32 height; -}; -struct vchiq_mmal_port_buffer {unsigned int num;/* number of buffers */ u32 size;/* size of buffers */
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 10/15 staging: bcm2835-camera: Replace BUG_ON with return error
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
The error conditions don't warrant taking the kernel down, so remove BUG_ON.
--- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +4 -3
@@ -302,8 +302,8 @@ static int buffer_prepare(struct vb2_buffer *vb)v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"%s: dev:%p, vb %p\n" , __func__, dev, vb); -BUG_ON (!dev->capture.port); -BUG_ON (!dev->capture.fmt); +if (!dev->capture.port || !dev->capture.fmt) +return -ENODEV ; size = dev->capture.stride * dev->capture.height;if (vb2_plane_size (vb,0 ) < size) {
@@ -1017,7 +1017,8 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev,struct mmal_fmt *mfmt =get_format (f);u32 remove_padding; -BUG_ON (!mfmt); +if (!mfmt) +return -EINVAL ;if (dev->capture.encode_component) { v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev,
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 11/15 staging: bcm2835-camera: Fix comment typos.
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
Fix a typo flagged by checkpatch, and another in the same line.
--- drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h +1 -1
@@ -37,7 +37,7 @@ enum mmal_port_type {* * most elements are informational only, the pointer values for * interogation messages are generally provided as additional -* strucures within the message. When used to set values only teh +* structures within the message. When used to set values only the * buffer_num, buffer_size and userdata parameters are writable. */ struct mmal_port {
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 12/12 staging: bcm2835-camera: Fix identation of tables
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
As requested by Mauro Carvalho Chehab in review.
--- .../bcm2835-camera/bcm2835-camera.c | 289 +++++++++--------- 1 file changed, 139 insertions(+), 150 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +139 -150
@@ -79,145 +79,132 @@ static const struct v4l2_fract/* video formats */ static struct mmal_fmt formats[] = { { - .name ="4:2:0, planar, YUV" , - .fourcc =V4L2_PIX_FMT_YUV420 , - .flags =0 , - .mmal =MMAL_ENCODING_I420 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="4:2:2, packed, YUYV" , - .fourcc =V4L2_PIX_FMT_YUYV , - .flags =0 , - .mmal =MMAL_ENCODING_YUYV , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="RGB24 (LE)" , - .fourcc =V4L2_PIX_FMT_RGB24 , - .flags =0 , - .mmal =MMAL_ENCODING_RGB24 , - .depth =24 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =3 , - .remove_padding =0 , - }, - { - .name ="JPEG" , - .fourcc =V4L2_PIX_FMT_JPEG , - .flags =V4L2_FMT_FLAG_COMPRESSED , - .mmal =MMAL_ENCODING_JPEG , - .depth =8 , - .mmal_component =MMAL_COMPONENT_IMAGE_ENCODE , - .ybbp =0 , - .remove_padding =0 , - }, - { - .name ="H264" , - .fourcc =V4L2_PIX_FMT_H264 , - .flags =V4L2_FMT_FLAG_COMPRESSED , - .mmal =MMAL_ENCODING_H264 , - .depth =8 , - .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , - .ybbp =0 , - .remove_padding =0 , - }, - { - .name ="MJPEG" , - .fourcc =V4L2_PIX_FMT_MJPEG , - .flags =V4L2_FMT_FLAG_COMPRESSED , - .mmal =MMAL_ENCODING_MJPEG , - .depth =8 , - .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , - .ybbp =0 , - .remove_padding =0 , - }, - { - .name ="4:2:2, packed, YVYU" , - .fourcc =V4L2_PIX_FMT_YVYU , - .flags =0 , - .mmal =MMAL_ENCODING_YVYU , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="4:2:2, packed, VYUY" , - .fourcc =V4L2_PIX_FMT_VYUY , - .flags =0 , - .mmal =MMAL_ENCODING_VYUY , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="4:2:2, packed, UYVY" , - .fourcc =V4L2_PIX_FMT_UYVY , - .flags =0 , - .mmal =MMAL_ENCODING_UYVY , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="4:2:0, planar, NV12" , - .fourcc =V4L2_PIX_FMT_NV12 , - .flags =0 , - .mmal =MMAL_ENCODING_NV12 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="RGB24 (BE)" , - .fourcc =V4L2_PIX_FMT_BGR24 , - .flags =0 , - .mmal =MMAL_ENCODING_BGR24 , - .depth =24 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =3 , - .remove_padding =0 , - }, - { - .name ="4:2:0, planar, YVU" , - .fourcc =V4L2_PIX_FMT_YVU420 , - .flags =0 , - .mmal =MMAL_ENCODING_YV12 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="4:2:0, planar, NV21" , - .fourcc =V4L2_PIX_FMT_NV21 , - .flags =0 , - .mmal =MMAL_ENCODING_NV21 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="RGB32 (BE)" , - .fourcc =V4L2_PIX_FMT_BGR32 , - .flags =0 , - .mmal =MMAL_ENCODING_BGRA , - .depth =32 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =4 , - .remove_padding =0 , - }, + .name ="4:2:0, planar, YUV" , + .fourcc =V4L2_PIX_FMT_YUV420 , + .flags =0 , + .mmal =MMAL_ENCODING_I420 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="4:2:2, packed, YUYV" , + .fourcc =V4L2_PIX_FMT_YUYV , + .flags =0 , + .mmal =MMAL_ENCODING_YUYV , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="RGB24 (LE)" , + .fourcc =V4L2_PIX_FMT_RGB24 , + .flags =0 , + .mmal =MMAL_ENCODING_RGB24 , + .depth =24 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =3 , + .remove_padding =0 , + }, { + .name ="JPEG" , + .fourcc =V4L2_PIX_FMT_JPEG , + .flags =V4L2_FMT_FLAG_COMPRESSED , + .mmal =MMAL_ENCODING_JPEG , + .depth =8 , + .mmal_component =MMAL_COMPONENT_IMAGE_ENCODE , + .ybbp =0 , + .remove_padding =0 , + }, { + .name ="H264" , + .fourcc =V4L2_PIX_FMT_H264 , + .flags =V4L2_FMT_FLAG_COMPRESSED , + .mmal =MMAL_ENCODING_H264 , + .depth =8 , + .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , + .ybbp =0 , + .remove_padding =0 , + }, { + .name ="MJPEG" , + .fourcc =V4L2_PIX_FMT_MJPEG , + .flags =V4L2_FMT_FLAG_COMPRESSED , + .mmal =MMAL_ENCODING_MJPEG , + .depth =8 , + .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , + .ybbp =0 , + .remove_padding =0 , + }, { + .name ="4:2:2, packed, YVYU" , + .fourcc =V4L2_PIX_FMT_YVYU , + .flags =0 , + .mmal =MMAL_ENCODING_YVYU , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="4:2:2, packed, VYUY" , + .fourcc =V4L2_PIX_FMT_VYUY , + .flags =0 , + .mmal =MMAL_ENCODING_VYUY , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="4:2:2, packed, UYVY" , + .fourcc =V4L2_PIX_FMT_UYVY , + .flags =0 , + .mmal =MMAL_ENCODING_UYVY , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="4:2:0, planar, NV12" , + .fourcc =V4L2_PIX_FMT_NV12 , + .flags =0 , + .mmal =MMAL_ENCODING_NV12 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="RGB24 (BE)" , + .fourcc =V4L2_PIX_FMT_BGR24 , + .flags =0 , + .mmal =MMAL_ENCODING_BGR24 , + .depth =24 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =3 , + .remove_padding =0 , + }, { + .name ="4:2:0, planar, YVU" , + .fourcc =V4L2_PIX_FMT_YVU420 , + .flags =0 , + .mmal =MMAL_ENCODING_YV12 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="4:2:0, planar, NV21" , + .fourcc =V4L2_PIX_FMT_NV21 , + .flags =0 , + .mmal =MMAL_ENCODING_NV21 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="RGB32 (BE)" , + .fourcc =V4L2_PIX_FMT_BGR32 , + .flags =0 , + .mmal =MMAL_ENCODING_BGRA , + .depth =32 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =4 , + .remove_padding =0 , + }, };static struct mmal_fmt *get_format (struct v4l2_format *f)
@@ -676,17 +663,19 @@ static int set_overlay_params(struct bm2835_mmal_dev *dev, struct vchiq_mmal_port *port) {struct mmal_parameter_displayregion prev_config = { - .set =MMAL_DISPLAY_SET_LAYER |MMAL_DISPLAY_SET_ALPHA | -MMAL_DISPLAY_SET_DEST_RECT |MMAL_DISPLAY_SET_FULLSCREEN , - .layer =PREVIEW_LAYER , - .alpha = dev->overlay.global_alpha, - .fullscreen =0 , - .dest_rect = { - .x = dev->overlay.w.left, - .y = dev->overlay.w.top, - .width = dev->overlay.w.width, - .height = dev->overlay.w.height, - }, + .set =MMAL_DISPLAY_SET_LAYER | +MMAL_DISPLAY_SET_ALPHA | +MMAL_DISPLAY_SET_DEST_RECT | +MMAL_DISPLAY_SET_FULLSCREEN , + .layer =PREVIEW_LAYER , + .alpha = dev->overlay.global_alpha, + .fullscreen =0 , + .dest_rect = { + .x = dev->overlay.w.left, + .y = dev->overlay.w.top, + .width = dev->overlay.w.width, + .height = dev->overlay.w.height, + }, }; return vchiq_mmal_port_parameter_set(dev->instance, port, MMAL_PARAMETER_DISPLAYREGION,
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 12/12] staging: bcm2835-camera: Fix identation of tables
Quoted 6 lines · Eric Anholt
From: Dave Stevenson <[email protected]>
As requested by Mauro Carvalho Chehab in review.
Signed-off-by Dave Stevenson <[email protected]>Signed-off-by Eric Anholt <[email protected]>
Ignore this one, the other 12/12 is just this with "identation" spelled right.
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 12/15 staging: bcm2835-camera: Fix indentation of tables
In reply to Eric AnholtFrom: Dave Stevenson <[email protected]>
As requested by Mauro Carvalho Chehab in review.
--- .../bcm2835-camera/bcm2835-camera.c | 289 +++++++++--------- 1 file changed, 139 insertions(+), 150 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +139 -150
@@ -79,145 +79,132 @@ static const struct v4l2_fract/* video formats */ static struct mmal_fmt formats[] = { { - .name ="4:2:0, planar, YUV" , - .fourcc =V4L2_PIX_FMT_YUV420 , - .flags =0 , - .mmal =MMAL_ENCODING_I420 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="4:2:2, packed, YUYV" , - .fourcc =V4L2_PIX_FMT_YUYV , - .flags =0 , - .mmal =MMAL_ENCODING_YUYV , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="RGB24 (LE)" , - .fourcc =V4L2_PIX_FMT_RGB24 , - .flags =0 , - .mmal =MMAL_ENCODING_RGB24 , - .depth =24 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =3 , - .remove_padding =0 , - }, - { - .name ="JPEG" , - .fourcc =V4L2_PIX_FMT_JPEG , - .flags =V4L2_FMT_FLAG_COMPRESSED , - .mmal =MMAL_ENCODING_JPEG , - .depth =8 , - .mmal_component =MMAL_COMPONENT_IMAGE_ENCODE , - .ybbp =0 , - .remove_padding =0 , - }, - { - .name ="H264" , - .fourcc =V4L2_PIX_FMT_H264 , - .flags =V4L2_FMT_FLAG_COMPRESSED , - .mmal =MMAL_ENCODING_H264 , - .depth =8 , - .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , - .ybbp =0 , - .remove_padding =0 , - }, - { - .name ="MJPEG" , - .fourcc =V4L2_PIX_FMT_MJPEG , - .flags =V4L2_FMT_FLAG_COMPRESSED , - .mmal =MMAL_ENCODING_MJPEG , - .depth =8 , - .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , - .ybbp =0 , - .remove_padding =0 , - }, - { - .name ="4:2:2, packed, YVYU" , - .fourcc =V4L2_PIX_FMT_YVYU , - .flags =0 , - .mmal =MMAL_ENCODING_YVYU , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="4:2:2, packed, VYUY" , - .fourcc =V4L2_PIX_FMT_VYUY , - .flags =0 , - .mmal =MMAL_ENCODING_VYUY , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="4:2:2, packed, UYVY" , - .fourcc =V4L2_PIX_FMT_UYVY , - .flags =0 , - .mmal =MMAL_ENCODING_UYVY , - .depth =16 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =2 , - .remove_padding =0 , - }, - { - .name ="4:2:0, planar, NV12" , - .fourcc =V4L2_PIX_FMT_NV12 , - .flags =0 , - .mmal =MMAL_ENCODING_NV12 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="RGB24 (BE)" , - .fourcc =V4L2_PIX_FMT_BGR24 , - .flags =0 , - .mmal =MMAL_ENCODING_BGR24 , - .depth =24 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =3 , - .remove_padding =0 , - }, - { - .name ="4:2:0, planar, YVU" , - .fourcc =V4L2_PIX_FMT_YVU420 , - .flags =0 , - .mmal =MMAL_ENCODING_YV12 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="4:2:0, planar, NV21" , - .fourcc =V4L2_PIX_FMT_NV21 , - .flags =0 , - .mmal =MMAL_ENCODING_NV21 , - .depth =12 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =1 , - .remove_padding =1 , - }, - { - .name ="RGB32 (BE)" , - .fourcc =V4L2_PIX_FMT_BGR32 , - .flags =0 , - .mmal =MMAL_ENCODING_BGRA , - .depth =32 , - .mmal_component =MMAL_COMPONENT_CAMERA , - .ybbp =4 , - .remove_padding =0 , - }, + .name ="4:2:0, planar, YUV" , + .fourcc =V4L2_PIX_FMT_YUV420 , + .flags =0 , + .mmal =MMAL_ENCODING_I420 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="4:2:2, packed, YUYV" , + .fourcc =V4L2_PIX_FMT_YUYV , + .flags =0 , + .mmal =MMAL_ENCODING_YUYV , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="RGB24 (LE)" , + .fourcc =V4L2_PIX_FMT_RGB24 , + .flags =0 , + .mmal =MMAL_ENCODING_RGB24 , + .depth =24 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =3 , + .remove_padding =0 , + }, { + .name ="JPEG" , + .fourcc =V4L2_PIX_FMT_JPEG , + .flags =V4L2_FMT_FLAG_COMPRESSED , + .mmal =MMAL_ENCODING_JPEG , + .depth =8 , + .mmal_component =MMAL_COMPONENT_IMAGE_ENCODE , + .ybbp =0 , + .remove_padding =0 , + }, { + .name ="H264" , + .fourcc =V4L2_PIX_FMT_H264 , + .flags =V4L2_FMT_FLAG_COMPRESSED , + .mmal =MMAL_ENCODING_H264 , + .depth =8 , + .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , + .ybbp =0 , + .remove_padding =0 , + }, { + .name ="MJPEG" , + .fourcc =V4L2_PIX_FMT_MJPEG , + .flags =V4L2_FMT_FLAG_COMPRESSED , + .mmal =MMAL_ENCODING_MJPEG , + .depth =8 , + .mmal_component =MMAL_COMPONENT_VIDEO_ENCODE , + .ybbp =0 , + .remove_padding =0 , + }, { + .name ="4:2:2, packed, YVYU" , + .fourcc =V4L2_PIX_FMT_YVYU , + .flags =0 , + .mmal =MMAL_ENCODING_YVYU , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="4:2:2, packed, VYUY" , + .fourcc =V4L2_PIX_FMT_VYUY , + .flags =0 , + .mmal =MMAL_ENCODING_VYUY , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="4:2:2, packed, UYVY" , + .fourcc =V4L2_PIX_FMT_UYVY , + .flags =0 , + .mmal =MMAL_ENCODING_UYVY , + .depth =16 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =2 , + .remove_padding =0 , + }, { + .name ="4:2:0, planar, NV12" , + .fourcc =V4L2_PIX_FMT_NV12 , + .flags =0 , + .mmal =MMAL_ENCODING_NV12 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="RGB24 (BE)" , + .fourcc =V4L2_PIX_FMT_BGR24 , + .flags =0 , + .mmal =MMAL_ENCODING_BGR24 , + .depth =24 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =3 , + .remove_padding =0 , + }, { + .name ="4:2:0, planar, YVU" , + .fourcc =V4L2_PIX_FMT_YVU420 , + .flags =0 , + .mmal =MMAL_ENCODING_YV12 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="4:2:0, planar, NV21" , + .fourcc =V4L2_PIX_FMT_NV21 , + .flags =0 , + .mmal =MMAL_ENCODING_NV21 , + .depth =12 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =1 , + .remove_padding =1 , + }, { + .name ="RGB32 (BE)" , + .fourcc =V4L2_PIX_FMT_BGR32 , + .flags =0 , + .mmal =MMAL_ENCODING_BGRA , + .depth =32 , + .mmal_component =MMAL_COMPONENT_CAMERA , + .ybbp =4 , + .remove_padding =0 , + }, };static struct mmal_fmt *get_format (struct v4l2_format *f)
@@ -676,17 +663,19 @@ static int set_overlay_params(struct bm2835_mmal_dev *dev, struct vchiq_mmal_port *port) {struct mmal_parameter_displayregion prev_config = { - .set =MMAL_DISPLAY_SET_LAYER |MMAL_DISPLAY_SET_ALPHA | -MMAL_DISPLAY_SET_DEST_RECT |MMAL_DISPLAY_SET_FULLSCREEN , - .layer =PREVIEW_LAYER , - .alpha = dev->overlay.global_alpha, - .fullscreen =0 , - .dest_rect = { - .x = dev->overlay.w.left, - .y = dev->overlay.w.top, - .width = dev->overlay.w.width, - .height = dev->overlay.w.height, - }, + .set =MMAL_DISPLAY_SET_LAYER | +MMAL_DISPLAY_SET_ALPHA | +MMAL_DISPLAY_SET_DEST_RECT | +MMAL_DISPLAY_SET_FULLSCREEN , + .layer =PREVIEW_LAYER , + .alpha = dev->overlay.global_alpha, + .fullscreen =0 , + .dest_rect = { + .x = dev->overlay.w.left, + .y = dev->overlay.w.top, + .width = dev->overlay.w.width, + .height = dev->overlay.w.height, + }, }; return vchiq_mmal_port_parameter_set(dev->instance, port, MMAL_PARAMETER_DISPLAYREGION,
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 13/15 staging: bcm2835-camera: Fix warnings about string ops on v4l2 uapi.
In reply to Eric AnholtThe v4l2 uapi uses u8[] for strings, so cast those to char * to avoid compiler warnings about unsigned vs signed with sprintf() and friends.
--- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +6 -6
@@ -693,7 +693,7 @@ static int vidioc_enum_fmt_vid_overlay(struct file *file, void *priv, fmt = &formats[f->index]; -strlcpy (f->description, fmt->name,sizeof (f->description)); +strlcpy ((char *)f->description, fmt->name,sizeof (f->description)); f->pixelformat = fmt->fourcc; f->flags = fmt->flags;
@@ -851,7 +851,7 @@ static int vidioc_enum_input(struct file *file, void *priv,return -EINVAL ; inp->type =V4L2_INPUT_TYPE_CAMERA ; -sprintf (inp->name,"Camera %u" , inp->index); +sprintf ((char *)inp->name,"Camera %u" , inp->index);return 0 ; }
@@ -879,11 +879,11 @@ static int vidioc_querycap(struct file *file, void *priv,vchiq_mmal_version (dev->instance, &major, &minor); -strcpy (cap->driver,"bm2835 mmal" ); -snprintf (cap->card,sizeof (cap->card),"mmal service %d.%d" , +strcpy ((char *)cap->driver,"bm2835 mmal" ); +snprintf ((char *)cap->card,sizeof (cap->card),"mmal service %d.%d" , major, minor); -snprintf (cap->bus_info,sizeof (cap->bus_info), +snprintf ((char *)cap->bus_info,sizeof (cap->bus_info),"platform:%s" , dev->v4l2_dev.name); cap->device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_VIDEO_OVERLAY |V4L2_CAP_STREAMING |V4L2_CAP_READWRITE ;
@@ -902,7 +902,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, fmt = &formats[f->index]; -strlcpy (f->description, fmt->name,sizeof (f->description)); +strlcpy ((char *)f->description, fmt->name,sizeof (f->description)); f->pixelformat = fmt->fourcc; f->flags = fmt->flags;
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH 13/15] staging: bcm2835-camera: Fix warnings about string ops on v4l2 uapi.
Not related to the patch, but that's weird. I get that it's part of the user API now, but why it u8 and can't it be changed?
regards,
dan carpenter
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 14/15 staging: bcm2835: Remove dead code related to framerate.
In reply to Eric AnholtFixes a compiler warning about a set-but-not-used variable. I think this was just leftover dead code from before set_framerate_params(), since that also sets up some mmal_parameter_rational structs for fps.
--- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +0 -5
@@ -1397,7 +1397,6 @@ static int vidioc_s_parm(struct file *file, void *priv, {struct bm2835_mmal_dev *dev =video_drvdata (file);struct v4l2_fract tpf; -struct mmal_parameter_rational fps_param;if (parm->type !=V4L2_BUF_TYPE_VIDEO_CAPTURE )return -EINVAL ;
@@ -1414,10 +1413,6 @@ static int vidioc_s_parm(struct file *file, void *priv, parm->parm.capture.readbuffers =1 ; parm->parm.capture.capability =V4L2_CAP_TIMEPERFRAME ; - fps_param.num =0 ;/* Select variable fps, and then use -* FPS_RANGE to select the actual limits. -*/ - fps_param.den =1 ;set_framerate_params (dev);return 0 ;
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
PATCH 15/15 staging: bcm2835: Fix mmal_port_parameter_get() signed/unsigned warnings.
In reply to Eric AnholtThe arg is a u32 *, so switch over to that in our declarations.
--- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +3 -3
@@ -492,7 +492,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) {struct bm2835_mmal_dev *dev =vb2_get_drv_priv (vq);int ret; -int parameter_size; +u32 parameter_size;v4l2_dbg (1 , bcm2835_v4l2_debug, &dev->v4l2_dev,"%s: dev:%p\n" , __func__, dev);
@@ -1489,7 +1489,7 @@ static int get_num_cameras(struct vchiq_mmal_instance *instance,int ret;struct vchiq_mmal_component *cam_info_component;struct mmal_parameter_camera_info_t cam_info = {0 }; -int param_size =sizeof (cam_info); +u32 param_size =sizeof (cam_info);int i;/* create a camera_info component */
@@ -1553,7 +1553,7 @@ static int __init mmal_init(struct bm2835_mmal_dev *dev)int ret;struct mmal_es_format_local *format;u32 supported_encodings[MAX_SUPPORTED_ENCODINGS ]; -int param_size; +u32 param_size;struct vchiq_mmal_component *camera; ret =vchiq_mmal_init (&dev->instance);
Signature · 6 lines
2.17.0 _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel