Re: [PATCH] [media] s5p-jpeg: fix recursive spinlock acquisition
Hi Mauro, This patch seems to have lost somehow. Could you help merging it? Thanks, Jacek Anaszewski On 05/29/2017 09:29 AM, Alexandre Courbot wrote: > Hi everyone, > > On Thu, Apr 27, 2017 at 4:35 AM, Jacek Anaszewski > wrote: >> On 04/26/2017 04:54 AM, Alexandre Courbot wrote: >>> On Wed, Apr 26, 2017 at 4:15 AM, Jacek Anaszewski >>> wrote: >>>> Hi Alexandre, >>>> >>>> Thanks for the patch. >>>> >>>> On 04/25/2017 08:19 AM, Alexandre Courbot wrote: >>>>> v4l2_m2m_job_finish(), which is called from the interrupt handler withHi s >>>>> slock acquired, can call the device_run() hook immediately if another >>>>> context was in the queue. This hook also acquires slock, resulting in >>>>> a deadlock for this scenario. >>>>> >>>>> Fix this by releasing slock right before calling v4l2_m2m_job_finish(). >>>>> This is safe to do as the state of the hardware cannot change before >>>>> v4l2_m2m_job_finish() is called anyway. >>>>> >>>>> Signed-off-by: Alexandre Courbot >>>>> --- >>>>> drivers/media/platform/s5p-jpeg/jpeg-core.c | 12 +--- >>>>> 1 file changed, 9 insertions(+), 3 deletions(-) >>>>> >>>>> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c >>>>> b/drivers/media/platform/s5p-jpeg/jpeg-core.c >>>>> index 52dc7941db65..223b4379929e 100644 >>>>> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c >>>>> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c >>>>> @@ -2642,13 +2642,13 @@ static irqreturn_t s5p_jpeg_irq(int irq, void >>>>> *dev_id) >>>>> if (curr_ctx->mode == S5P_JPEG_ENCODE) >>>>> vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload_size); >>>>> v4l2_m2m_buf_done(dst_buf, state); >>>>> - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>>>> >>>>> curr_ctx->subsampling = s5p_jpeg_get_subsampling_mode(jpeg->regs); >>>>> spin_unlock(&jpeg->slock); >>>>> >>>>> s5p_jpeg_clear_int(jpeg->regs); >>>>> >>>>> + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>>>> return IRQ_HANDLED; >>>>> } >>>>> >>>>> @@ -2707,11 +2707,12 @@ static irqreturn_t exynos4_jpeg_irq(int irq, void >>>>> *priv) >>>>> v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_ERROR); >>>>> } >>>>> >>>>> - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>>>> if (jpeg->variant->version == SJPEG_EXYNOS4) >>>>> curr_ctx->subsampling = >>>>> exynos4_jpeg_get_frame_fmt(jpeg->regs); >>>>> >>>>> spin_unlock(&jpeg->slock); >>>>> + >>>>> + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>>>> return IRQ_HANDLED; >>>>> } >>>>> >>>>> @@ -2770,10 +2771,15 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, >>>>> void *dev_id) >>>>> if (curr_ctx->mode == S5P_JPEG_ENCODE) >>>>> vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload_size); >>>>> v4l2_m2m_buf_done(dst_buf, state); >>>>> - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>>>> >>>>> curr_ctx->subsampling = >>>>> exynos3250_jpeg_get_subsampling_mode(jpeg->regs); >>>>> + >>>>> + spin_unlock(&jpeg->slock); >>>>> + >>>>> + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>>>> + return IRQ_HANDLED; >>>>> + >>>>> exit_unlock: >>>>> spin_unlock(&jpeg->slock); >>>>> return IRQ_HANDLED; >>>>> >>>> >>>> Acked-by: Jacek Anaszewski >>>> >>>> Just out of curiosity - could you share how you discovered the problem - >>>> by some static checkers or trying to use the driver? >>> >>> We discovered this issue after adding a new unit test for the jpeg >>> codec in Chromium OS: >>> >>> https://bugs.chromium.org/p/chromium/issues/detail?id=705971 >>> >>> >From what I understand the test spawns different processes that access >>> the codec device concurrently, creating the situation leading to the >>> bug. >> >> Thanks for the explanation. Nice fix. > > Gentle ping as I am not seeing this patch in the tree yet. Thanks. > >> >>> On a slightly related note, I was thinking whether it would make sense >>> to move the call to v4l2_m2m_job_finish() (and maybe other parts of >>> the current interrupt handler) into a worker or a threaded interrupt >>> handler so as to reduce the time we spend with interrupts disabled. >>> Can I have your input on this idea? >> >> Right, all remaining drivers call it from workers. >> Feel free to submit a patch. >> >> -- >> Best regards, >> Jacek Anaszewski >
Re: [PATCH 1/9] [media] s5p-jpeg: Reset the Codec before doing a soft reset
Hi Thierry, On 06/02/2017 06:02 PM, Thierry Escande wrote: > From: Abhilash Kesavan > > This patch resets the encoding and decoding register bits before doing a > soft reset. > > Signed-off-by: Tony K Nadackal > Signed-off-by: Thierry Escande > --- > drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c > b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c > index a1d823a..9ad8f6d 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c > @@ -21,6 +21,10 @@ void exynos4_jpeg_sw_reset(void __iomem *base) > unsigned int reg; > > reg = readl(base + EXYNOS4_JPEG_CNTL_REG); > + writel(reg & ~(EXYNOS4_DEC_MODE | EXYNOS4_ENC_MODE), > +base + EXYNOS4_JPEG_CNTL_REG); Why is it required? It would be nice if commit message explained that. > + reg = readl(base + EXYNOS4_JPEG_CNTL_REG); > writel(reg & ~EXYNOS4_SOFT_RESET_HI, base + EXYNOS4_JPEG_CNTL_REG); > > udelay(100); > -- Best regards, Jacek Anaszewski
Re: [PATCH 2/9] [media] s5p-jpeg: Call jpeg_bound_align_image after qbuf
Hi Thierry, Thanks for the patch. On 06/02/2017 06:02 PM, Thierry Escande wrote: > From: Tony K Nadackal > > When queuing an OUTPUT buffer for decoder, s5p_jpeg_parse_hdr() > function parses the input jpeg file and takes the width and height > parameters from its header. These new width/height values will be used > for the calculation of stride. HX_JPEG Hardware needs the width and > height values aligned on a 16 bits boundary. This width/height alignment > is handled in the s5p_jpeg_s_fmt_vid_cap() function during the S_FMT > ioctl call. > > But if user space calls the QBUF of OUTPUT buffer after the S_FMT of > CAPTURE buffer, these aligned values will be replaced by the values in > jpeg header. I assume that you may want to avoid re-setting the capture buf format when decoding a stream of JPEGs and you are certain that all of them have the same subsampling. Nonetheless, please keep in mind that in case of Exynos4x12 SoCs there is a risk of permanent decoder hangup if you'd try to decode to a YUV with lower subsampling than the one of input JPEG. s5p_jpeg_try_fmt_vid_cap() does a suitable adjustment to avoid the problem. I'd add a comment over this call to jpeg_bound_align_image() that resigning from executing S_FMT on capture buf for each JPEG image can result in a hardware hangup if forbidden decoding will be enforced. > If the width/height values of jpeg are not aligned, the > decoder output will be corrupted. So in this patch we call > jpeg_bound_align_image() to align the width/height values of Capture > buffer in s5p_jpeg_buf_queue(). > > Signed-off-by: Tony K Nadackal > Signed-off-by: Thierry Escande > --- > drivers/media/platform/s5p-jpeg/jpeg-core.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c > b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index 52dc794..6fb1ab4 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -2523,6 +2523,13 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > q_data = &ctx->cap_q; > q_data->w = tmp.w; > q_data->h = tmp.h; > + > + jpeg_bound_align_image(ctx, &q_data->w, S5P_JPEG_MIN_WIDTH, > +S5P_JPEG_MAX_WIDTH, q_data->fmt->h_align, > +&q_data->h, S5P_JPEG_MIN_HEIGHT, > +S5P_JPEG_MAX_HEIGHT, q_data->fmt->v_align > + ); > + q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3; > } > > v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vbuf); > -- Best regards, Jacek Anaszewski
Re: [PATCH 4/9] [media] s5p-jpeg: Decode 4:1:1 chroma subsampling format
Hi Thierry, On 06/02/2017 06:02 PM, Thierry Escande wrote: > From: Tony K Nadackal > > This patch adds support for decoding 4:1:1 chroma subsampling in the > jpeg header parsing function. > > Signed-off-by: Tony K Nadackal > Signed-off-by: Thierry Escande > --- > drivers/media/platform/s5p-jpeg/jpeg-core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c > b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index 0d83948..770a709 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -1236,6 +1236,9 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data > *result, > case 0x33: > ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; > break; > + case 0x41: > + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_411; > + break; > default: > return false; > } > Acked-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski
Re: [PATCH 5/9] [media] s5p-jpeg: Add IOMMU support
Cc Marek Szyprowski. Marek, could you share your opinion about this patch? On 06/02/2017 06:02 PM, Thierry Escande wrote: > From: Tony K Nadackal > > This patch adds support for IOMMU s5p-jpeg driver if the Exynos IOMMU > and ARM DMA IOMMU configurations are supported. The address space is > created with size limited to 256M and base address set to 0x2000. > > Signed-off-by: Tony K Nadackal > Signed-off-by: Thierry Escande > --- > drivers/media/platform/s5p-jpeg/jpeg-core.c | 77 > + > 1 file changed, 77 insertions(+) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c > b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index 770a709..5569b99 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -28,6 +28,14 @@ > #include > #include > #include > +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU) > +#include > +#include > +#include > +#include > +#include > +#include > +#endif > > #include "jpeg-core.h" > #include "jpeg-hw-s5p.h" > @@ -35,6 +43,10 @@ > #include "jpeg-hw-exynos3250.h" > #include "jpeg-regs.h" > > +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU) > +static struct dma_iommu_mapping *mapping; > +#endif > + > static struct s5p_jpeg_fmt sjpeg_formats[] = { > { > .name = "JPEG JFIF", > @@ -956,6 +968,60 @@ static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx > *ctx) > } > } > > +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU) > +static int jpeg_iommu_init(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + int err; > + > + mapping = arm_iommu_create_mapping(&platform_bus_type, 0x2000, > +SZ_512M); > + if (IS_ERR(mapping)) { > + dev_err(dev, "IOMMU mapping failed\n"); > + return PTR_ERR(mapping); > + } > + > + dev->dma_parms = devm_kzalloc(dev, sizeof(*dev->dma_parms), GFP_KERNEL); > + if (!dev->dma_parms) { > + err = -ENOMEM; > + goto error_alloc; > + } > + > + err = dma_set_max_seg_size(dev, 0xu); > + if (err) > + goto error; > + > + err = arm_iommu_attach_device(dev, mapping); > + if (err) > + goto error; > + > + return 0; > + > +error: > + devm_kfree(dev, dev->dma_parms); > + dev->dma_parms = NULL; > + > +error_alloc: > + arm_iommu_release_mapping(mapping); > + mapping = NULL; > + > + return err; > +} > + > +static void jpeg_iommu_deinit(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + > + if (mapping) { > + arm_iommu_detach_device(dev); > + devm_kfree(dev, dev->dma_parms); > + dev->dma_parms = NULL; > + arm_iommu_release_mapping(mapping); > + mapping = NULL; > + } > +} > +#endif > + > /* > * > > * Device file operations > @@ -2816,6 +2882,13 @@ static int s5p_jpeg_probe(struct platform_device *pdev) > spin_lock_init(&jpeg->slock); > jpeg->dev = &pdev->dev; > > +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU) > + ret = jpeg_iommu_init(pdev); > + if (ret) { > + dev_err(&pdev->dev, "IOMMU Initialization failed\n"); > + return ret; > + } > +#endif > /* memory-mapped registers */ > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > > @@ -2962,6 +3035,10 @@ static int s5p_jpeg_remove(struct platform_device > *pdev) > clk_disable_unprepare(jpeg->clocks[i]); > } > > +#if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU) > + jpeg_iommu_deinit(pdev); > +#endif > + > return 0; > } > > -- Best regards, Jacek Anaszewski
Re: [PATCH 6/9] [media] s5p-jpeg: Add support for resolution change event
ctx->state = JPEGCTX_RUNNING; > + } > + > pm_runtime_put(ctx->jpeg->dev); > } > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h > b/drivers/media/platform/s5p-jpeg/jpeg-core.h > index 4492a35..9aa26bd 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h > @@ -98,6 +98,11 @@ enum exynos4_jpeg_img_quality_level { > QUALITY_LEVEL_4,/* low */ > }; > > +enum s5p_jpeg_ctx_state { > + JPEGCTX_RUNNING = 0, > + JPEGCTX_RESOLUTION_CHANGE, > +}; > + > /** > * struct s5p_jpeg - JPEG IP abstraction > * @lock:the mutex protecting this structure > @@ -220,6 +225,7 @@ struct s5p_jpeg_q_data { > * @hdr_parsed: set if header has been parsed during > decompression > * @crop_altered:set if crop rectangle has been altered by the user space > * @ctrl_handler:controls handler > + * @state: state of the context > */ > struct s5p_jpeg_ctx { > struct s5p_jpeg *jpeg; > @@ -235,6 +241,7 @@ struct s5p_jpeg_ctx { > boolhdr_parsed; > boolcrop_altered; > struct v4l2_ctrl_handler ctrl_handler; > + enum s5p_jpeg_ctx_state state; > }; > > /** > -- Best regards, Jacek Anaszewski
Re: [PATCH 7/9] [media] s5p-jpeg: Change sclk_jpeg to 166MHz for Exynos5250
Cc Marek and Sylwester. On 06/02/2017 06:02 PM, Thierry Escande wrote: > From: henryhsu > > The default clock parent of jpeg on Exynos5250 is fin_pll, which is > 24MHz. We have to change the clock parent to CPLL, which is 333MHz, > and set sclk_jpeg to 166MHz. > > Signed-off-by: Heng-Ruey Hsu > Signed-off-by: Thierry Escande > --- > drivers/media/platform/s5p-jpeg/jpeg-core.c | 47 > + > 1 file changed, 47 insertions(+) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c > b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index 7a7acbc..430e925 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -969,6 +969,44 @@ static void exynos4_jpeg_parse_q_tbl(struct s5p_jpeg_ctx > *ctx) > } > } > > +static int exynos4_jpeg_set_sclk_rate(struct s5p_jpeg *jpeg, struct clk > *sclk) Why here exynos4 and in the subject Exynos5250? > +{ > + struct clk *mout_jpeg; > + struct clk *sclk_cpll; > + int ret; > + > + mout_jpeg = clk_get(jpeg->dev, "mout_jpeg"); > + if (IS_ERR(mout_jpeg)) { > + dev_err(jpeg->dev, "mout_jpeg clock not available: %ld\n", > + PTR_ERR(mout_jpeg)); > + return PTR_ERR(mout_jpeg); > + } > + > + sclk_cpll = clk_get(jpeg->dev, "sclk_cpll"); > + if (IS_ERR(sclk_cpll)) { > + dev_err(jpeg->dev, "sclk_cpll clock not available: %ld\n", > + PTR_ERR(sclk_cpll)); > + clk_put(mout_jpeg); > + return PTR_ERR(sclk_cpll); > + } > + > + ret = clk_set_parent(mout_jpeg, sclk_cpll); > + clk_put(sclk_cpll); > + clk_put(mout_jpeg); > + if (ret) { > + dev_err(jpeg->dev, "clk_set_parent failed: %d\n", ret); > + return ret; > + } > + > + ret = clk_set_rate(sclk, 166500 * 1000); > + if (ret) { > + dev_err(jpeg->dev, "clk_set_rate failed: %d\n", ret); > + return ret; > + } > + > + return 0; > +} > + > #if defined(CONFIG_EXYNOS_IOMMU) && defined(CONFIG_ARM_DMA_USE_IOMMU) > static int jpeg_iommu_init(struct platform_device *pdev) > { > @@ -2974,6 +3012,15 @@ static int s5p_jpeg_probe(struct platform_device *pdev) > jpeg->variant->clk_names[i]); > return PTR_ERR(jpeg->clocks[i]); > } > + > + if (jpeg->variant->version == SJPEG_EXYNOS4 && > + !strncmp(jpeg->variant->clk_names[i], > + "sclk", strlen("sclk"))) { > + ret = exynos4_jpeg_set_sclk_rate(jpeg, > + jpeg->clocks[i]); > + if (ret) > + return ret; > + } > } > > /* v4l2 device */ > -- Best regards, Jacek Anaszewski
Re: [PATCH 9/9] [media] s5p-jpeg: Add support for multi-planar APIs
oc_s_fmt_vid_out_mplane= s5p_jpeg_s_fmt_vid_out_mplane, > + > .vidioc_reqbufs = v4l2_m2m_ioctl_reqbufs, > .vidioc_querybuf= v4l2_m2m_ioctl_querybuf, > .vidioc_qbuf= v4l2_m2m_ioctl_qbuf, > @@ -2648,7 +2771,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue); > > if (ctx->mode == S5P_JPEG_DECODE && > - vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { > + vb->vb2_queue->type == ctx->out_q.type) { > static const struct v4l2_event ev_src_ch = { > .type = V4L2_EVENT_SOURCE_CHANGE, > .u.src_change.changes = V4L2_EVENT_SRC_CH_RESOLUTION, > @@ -2657,8 +2780,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > u32 ori_w; > u32 ori_h; > > - dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, > - V4L2_BUF_TYPE_VIDEO_CAPTURE); > + dst_vq = v4l2_m2m_get_vq(ctx->fh.m2m_ctx, ctx->cap_q.type); > ori_w = ctx->out_q.w; > ori_h = ctx->out_q.h; > > @@ -2708,7 +2830,7 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q) >* subsampling. Update capture queue when the stream is off. >*/ > if (ctx->state == JPEGCTX_RESOLUTION_CHANGE && > - q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) { > + !V4L2_TYPE_IS_OUTPUT(q->type)) { > s5p_jpeg_set_capture_queue_data(ctx); > ctx->state = JPEGCTX_RUNNING; > } > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h > b/drivers/media/platform/s5p-jpeg/jpeg-core.h > index 9aa26bd..302a297 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h > @@ -196,6 +196,7 @@ struct s5p_jpeg_marker { > * @sof_len: SOF0 marker's payload length (without length field itself) > * @components: number of image components > * @size:image buffer size in bytes > + * @type:buffer type of the queue (enum v4l2_buf_type) > */ > struct s5p_jpeg_q_data { > struct s5p_jpeg_fmt *fmt; > @@ -208,6 +209,7 @@ struct s5p_jpeg_q_data { > u32 sof_len; > u32 components; > u32 size; > + u32 type; > }; > > /** > -- Best regards, Jacek Anaszewski
Re: [PATCH 1/9] [media] s5p-jpeg: Reset the Codec before doing a soft reset
Hi Thierry, On 06/07/2017 02:34 PM, Thierry Escande wrote: > Hi Jacek, > > On 02/06/2017 21:50, Jacek Anaszewski wrote: >> Hi Thierry, >> >> On 06/02/2017 06:02 PM, Thierry Escande wrote: >>> From: Abhilash Kesavan >>> >>> This patch resets the encoding and decoding register bits before doing a >>> soft reset. >>> >>> Signed-off-by: Tony K Nadackal >>> Signed-off-by: Thierry Escande >>> --- >>> drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 4 >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c >>> b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c >>> index a1d823a..9ad8f6d 100644 >>> --- a/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c >>> +++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c >>> @@ -21,6 +21,10 @@ void exynos4_jpeg_sw_reset(void __iomem *base) >>> unsigned int reg; >>> reg = readl(base + EXYNOS4_JPEG_CNTL_REG); >>> +writel(reg & ~(EXYNOS4_DEC_MODE | EXYNOS4_ENC_MODE), >>> + base + EXYNOS4_JPEG_CNTL_REG); >> >> Why is it required? It would be nice if commit message explained that. > > Unfortunately the bug entry in the ChromeOS issue tracker does not > mention more information about that and the patch author is no more > reachable on that email address. > > So unless someone else knows the answer I won't be able to give more > explanation in the commit message... Unfortunately I don't have longer access to the hardware and can't test these changes. Have you tested them, or just cherry-picked from the bug tracker? -- Best regards, Jacek Anaszewski
Re: [PATCH 4/8] v4l2-flash: Use led_classdev instead of led_classdev_flash for indicator
device *dev, struct fwnode_handle *fwn, > struct led_classdev_flash *fled_cdev, > - struct led_classdev_flash *iled_cdev, > + struct led_classdev *iled_cdev, > const struct v4l2_flash_ops *ops, > struct v4l2_flash_config *config); > > @@ -140,7 +140,7 @@ void v4l2_flash_release(struct v4l2_flash *v4l2_flash); > static inline struct v4l2_flash *v4l2_flash_init( > struct device *dev, struct fwnode_handle *fwn, > struct led_classdev_flash *fled_cdev, > - struct led_classdev_flash *iled_cdev, > + struct led_classdev *iled_cdev, > const struct v4l2_flash_ops *ops, > struct v4l2_flash_config *config) > { > Reviewed-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski
Re: [PATCH 5/8] v4l2-flash: Flash ops aren't mandatory
Hi Sakari, On 06/14/2017 11:47 AM, Sakari Ailus wrote: > None of the flash operations are not mandatory and therefore there should > be no need for the flash ops structure either. Accept NULL. > > Signed-off-by: Sakari Ailus > --- > drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c > b/drivers/media/v4l2-core/v4l2-flash-led-class.c > index 6d69119..fdb79da 100644 > --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c > +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c > @@ -18,7 +18,7 @@ > #include > > #define has_flash_op(v4l2_flash, op) \ > - (v4l2_flash && v4l2_flash->ops->op) > + (v4l2_flash && v4l2_flash->ops && v4l2_flash->ops->op) This change doesn't seem to be related to the patch subject. > #define call_flash_op(v4l2_flash, op, arg) \ > (has_flash_op(v4l2_flash, op) ? \ > @@ -618,7 +618,7 @@ struct v4l2_flash *v4l2_flash_init( > struct v4l2_subdev *sd; > int ret; > > - if (!fled_cdev || !ops || !config) > + if (!fled_cdev || !config) > return ERR_PTR(-EINVAL); > > led_cdev = &fled_cdev->led_cdev; > -- Best regards, Jacek Anaszewski
Re: [PATCH 6/8] leds: as3645a: Add LED flash class driver
rval; > +} > + > +static int as3645a_led_class_setup(struct as3645a *flash) > +{ > + struct led_classdev *fled_cdev = &flash->fled.led_cdev; > + struct led_classdev *iled_cdev = &flash->iled_cdev; > + struct led_flash_setting *cfg; > + int rval; > + > + iled_cdev->name = "as3645a indicator"; > + iled_cdev->brightness_set_blocking = as3645a_set_indicator_brightness; > + iled_cdev->max_brightness = > + flash->cfg.indicator_max_ua / AS_INDICATOR_INTENSITY_STEP; > + > + rval = led_classdev_register(&flash->client->dev, iled_cdev); > + if (rval < 0) > + return rval; > + > + cfg = &flash->fled.brightness; > + cfg->min = AS_FLASH_INTENSITY_MIN; > + cfg->max = flash->cfg.flash_max_ua; > + cfg->step = AS_FLASH_INTENSITY_STEP; > + cfg->val = flash->cfg.flash_max_ua; > + > + cfg = &flash->fled.timeout; > + cfg->min = AS_FLASH_TIMEOUT_MIN; > + cfg->max = flash->cfg.flash_timeout_us; > + cfg->step = AS_FLASH_TIMEOUT_STEP; > + cfg->val = flash->cfg.flash_timeout_us; > + > + flash->fled.ops = &as3645a_led_flash_ops; > + > + fled_cdev->name = "as3645a flash"; LED class device name should be taken from label DT property, or DT node name if the former wasn't defined. Also LED device naming convention defines colon as a separator between name segments. > + fled_cdev->brightness_set_blocking = as3645a_set_assist_brightness; > + /* Value 0 is off in LED class. */ > + fled_cdev->max_brightness = > + as3645a_current_to_reg(flash, false, > +flash->cfg.assist_max_ua) + 1; > + fled_cdev->flags = LED_DEV_CAP_FLASH; > + > + rval = led_classdev_flash_register(&flash->client->dev, &flash->fled); > + if (rval) { > + led_classdev_unregister(iled_cdev); > + dev_err(&flash->client->dev, > + "led_classdev_flash_register() failed, error %d\n", > + rval); > + } > + > + return rval; > +} > + > +static int as3645a_v4l2_setup(struct as3645a *flash) > +{ > + struct led_classdev_flash *fled = &flash->fled; > + struct led_classdev *led = &fled->led_cdev; > + struct v4l2_flash_config cfg = { > + .torch_intensity = { > + .min = AS_TORCH_INTENSITY_MIN, > + .max = flash->cfg.assist_max_ua, > + .step = AS_TORCH_INTENSITY_STEP, > + .val = flash->cfg.assist_max_ua, > + }, > + .indicator_intensity = { > + .min = AS_INDICATOR_INTENSITY_MIN, > + .max = flash->cfg.indicator_max_ua, > + .step = AS_INDICATOR_INTENSITY_STEP, > + .val = flash->cfg.indicator_max_ua, > + }, > + }; > + > + strlcpy(cfg.dev_name, led->name, sizeof(cfg.dev_name)); > + > + flash->vf = v4l2_flash_init(&flash->client->dev, NULL, &flash->fled, > + &flash->iled_cdev, NULL, &cfg); > + if (IS_ERR(flash->vf)) > + return PTR_ERR(flash->vf); > + > + return 0; > +} > + > +static int as3645a_probe(struct i2c_client *client) > +{ > + struct as3645a *flash; > + int rval; > + > + if (client->dev.of_node == NULL) > + return -ENODEV; > + > + flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); > + if (flash == NULL) > + return -ENOMEM; > + > + flash->client = client; > + > + rval = as3645a_parse_node(flash, client->dev.of_node); > + if (rval < 0) > + return rval; > + > + rval = as3645a_detect(flash); > + if (rval < 0) > + return rval; > + > + mutex_init(&flash->mutex); > + i2c_set_clientdata(client, flash); > + > + rval = as3645a_setup(flash); > + if (rval) > + goto out_mutex_destroy; > + > + rval = as3645a_led_class_setup(flash); > + if (rval) > + goto out_mutex_destroy; > + > + rval = as3645a_v4l2_setup(flash); > + if (rval) > + goto out_led_classdev_flash_unregister; > + > + return 0; > + > +out_led_classdev_flash_unregister: > + led_classdev_flash_unregister(&flash->fled); > + > +out_mutex_destroy: > + mutex_destroy(&flash->mutex); > + > + return rval; > +} > + > +static int as3645a_remove(struct i2c_client *client) > +{ > + struct as3645a *flash = i2c_get_clientdata(client); > + > + as3645a_set_control(flash, AS_MODE_EXT_TORCH, false); > + > + v4l2_flash_release(flash->vf); > + > + led_classdev_flash_unregister(&flash->fled); > + led_classdev_unregister(&flash->iled_cdev); > + > + mutex_destroy(&flash->mutex); > + > + return 0; > +} > + > +static const struct of_device_id as3645a_of_table[] = { > + { .compatible = "ams,as3645a" }, > + { }, > +}; > +MODULE_DEVICE_TABLE(of, as3645a_of_table); > + > +SIMPLE_DEV_PM_OPS(as3645a_pm_ops, as3645a_resume, as3645a_suspend); > + > +static struct i2c_driver as3645a_i2c_driver = { > + .driver = { > + .of_match_table = as3645a_of_table, > + .name = AS_NAME, > + .pm = &as3645a_pm_ops, > + }, > + .probe_new = as3645a_probe, > + .remove = as3645a_remove, > +}; > + > +module_i2c_driver(as3645a_i2c_driver); > + > +MODULE_AUTHOR("Laurent Pinchart "); > +MODULE_AUTHOR("Sakari Ailus "); > +MODULE_DESCRIPTION("LED flash driver for AS3645A, LM3555 and their clones"); > +MODULE_LICENSE("GPL v2"); > -- Best regards, Jacek Anaszewski
Re: [PATCH 5/8] v4l2-flash: Flash ops aren't mandatory
Hi Sakari, On 06/14/2017 11:19 PM, Sakari Ailus wrote: > Hi Jacek, > > On Wed, Jun 14, 2017 at 11:14:13PM +0200, Jacek Anaszewski wrote: >> Hi Sakari, >> >> On 06/14/2017 11:47 AM, Sakari Ailus wrote: >>> None of the flash operations are not mandatory and therefore there should >>> be no need for the flash ops structure either. Accept NULL. >>> >>> Signed-off-by: Sakari Ailus >>> --- >>> drivers/media/v4l2-core/v4l2-flash-led-class.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c >>> b/drivers/media/v4l2-core/v4l2-flash-led-class.c >>> index 6d69119..fdb79da 100644 >>> --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c >>> +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c >>> @@ -18,7 +18,7 @@ >>> #include >>> >>> #define has_flash_op(v4l2_flash, op) \ >>> - (v4l2_flash && v4l2_flash->ops->op) >>> + (v4l2_flash && v4l2_flash->ops && v4l2_flash->ops->op) >> >> This change doesn't seem to be related to the patch subject. > > Yes, it is: if there's a chance that ops is NULL, then you have to test here > you actually have the ops struct around. The test is no longer in > v4l2_flash_init(). Indeed. Reviewed-by: Jacek Anaszewski >>> #define call_flash_op(v4l2_flash, op, arg) \ >>> (has_flash_op(v4l2_flash, op) ? \ >>> @@ -618,7 +618,7 @@ struct v4l2_flash *v4l2_flash_init( >>> struct v4l2_subdev *sd; >>> int ret; >>> >>> - if (!fled_cdev || !ops || !config) >>> + if (!fled_cdev || !config) >>> return ERR_PTR(-EINVAL); >>> >>> led_cdev = &fled_cdev->led_cdev; >>> > -- Best regards, Jacek Anaszewski
Re: [PATCH 6/8] leds: as3645a: Add LED flash class driver
Hi Sakari, On 06/15/2017 12:10 AM, Sakari Ailus wrote: > Hi Jacek, > > Thanks for the review! You're welcome! > I have to say I found the v4l2-flash-led-class framework quite useful, now > that I refactored a driver for using it. Now we have a user for the > indicator, too. :-) Nice :-). I'm also surprised that v4l2-flash API is also used in drivers/staging/greybus/light.c which popped up with kbuild test robot complaints. > On Wed, Jun 14, 2017 at 11:15:24PM +0200, Jacek Anaszewski wrote: >>> +static __maybe_unused int as3645a_suspend(struct device *dev) >>> +{ >>> + struct i2c_client *client = to_i2c_client(dev); >>> + struct as3645a *flash = i2c_get_clientdata(client); >>> + int rval; >>> + >>> + rval = as3645a_set_control(flash, AS_MODE_EXT_TORCH, false); >>> + dev_dbg(dev, "Suspend %s\n", rval < 0 ? "failed" : "ok"); >>> + >>> + return rval; >>> +} >>> + >>> +static __maybe_unused int as3645a_resume(struct device *dev) >>> +{ >>> + struct i2c_client *client = to_i2c_client(dev); >>> + struct as3645a *flash = i2c_get_clientdata(client); >>> + int rval; >>> + >>> + rval = as3645a_setup(flash); >>> + >> >> nitpicking: inconsistent coding style - there is no empty line before >> dev_dbg() in the as3645a_suspend(). > > Added one for as3645a_suspend() --- it should have been there. > >> >>> + dev_dbg(dev, "Resume %s\n", rval < 0 ? "fail" : "ok"); >>> + >>> + return rval; >>> +} > > ... > >>> +static int as3645a_led_class_setup(struct as3645a *flash) >>> +{ >>> + struct led_classdev *fled_cdev = &flash->fled.led_cdev; >>> + struct led_classdev *iled_cdev = &flash->iled_cdev; >>> + struct led_flash_setting *cfg; >>> + int rval; >>> + >>> + iled_cdev->name = "as3645a indicator"; >>> + iled_cdev->brightness_set_blocking = as3645a_set_indicator_brightness; >>> + iled_cdev->max_brightness = >>> + flash->cfg.indicator_max_ua / AS_INDICATOR_INTENSITY_STEP; >>> + >>> + rval = led_classdev_register(&flash->client->dev, iled_cdev); >>> + if (rval < 0) >>> + return rval; >>> + >>> + cfg = &flash->fled.brightness; >>> + cfg->min = AS_FLASH_INTENSITY_MIN; >>> + cfg->max = flash->cfg.flash_max_ua; >>> + cfg->step = AS_FLASH_INTENSITY_STEP; >>> + cfg->val = flash->cfg.flash_max_ua; >>> + >>> + cfg = &flash->fled.timeout; >>> + cfg->min = AS_FLASH_TIMEOUT_MIN; >>> + cfg->max = flash->cfg.flash_timeout_us; >>> + cfg->step = AS_FLASH_TIMEOUT_STEP; >>> + cfg->val = flash->cfg.flash_timeout_us; >>> + >>> + flash->fled.ops = &as3645a_led_flash_ops; >>> + >>> + fled_cdev->name = "as3645a flash"; >> >> LED class device name should be taken from label DT property, >> or DT node name if the former wasn't defined. >> >> Also LED device naming convention defines colon as a separator >> between name segments. > > Right. I'll fix that. > > I just realised I'm missing DT binding documentation for this device; I'll > add that, too. > > Is the preference to allow freely chosen node names for the LEDs? Now that > there's the label, too, this appears to be somewhat duplicated information. It depends on whether the sub-leds are identified by reg property. In this case usually common prefix is used followed by reg value, e.g. led@1, led@2 etc. Otherwise prevailing scheme is e.g.: blue-power { ... label = "netxbig:blue:power"; } -- Best regards, Jacek Anaszewski
Re: [PATCH 6/8] leds: as3645a: Add LED flash class driver
On 06/15/2017 03:34 PM, Sakari Ailus wrote: > Hi Jacek, > > On Thu, Jun 15, 2017 at 03:01:47PM +0200, Jacek Anaszewski wrote: >> Hi Sakari, >> >> On 06/15/2017 12:10 AM, Sakari Ailus wrote: >>> Hi Jacek, >>> >>> Thanks for the review! >> >> You're welcome! >> >>> I have to say I found the v4l2-flash-led-class framework quite useful, now >>> that I refactored a driver for using it. Now we have a user for the >>> indicator, too. :-) >> >> Nice :-). I'm also surprised that v4l2-flash API is also used in >> drivers/staging/greybus/light.c which popped up with kbuild test robot >> complaints. > > I missed that on the first round of the submission as well. I'll fix that > in v2. > >> >>> On Wed, Jun 14, 2017 at 11:15:24PM +0200, Jacek Anaszewski wrote: >>>>> +static __maybe_unused int as3645a_suspend(struct device *dev) >>>>> +{ >>>>> + struct i2c_client *client = to_i2c_client(dev); >>>>> + struct as3645a *flash = i2c_get_clientdata(client); >>>>> + int rval; >>>>> + >>>>> + rval = as3645a_set_control(flash, AS_MODE_EXT_TORCH, false); >>>>> + dev_dbg(dev, "Suspend %s\n", rval < 0 ? "failed" : "ok"); >>>>> + >>>>> + return rval; >>>>> +} >>>>> + >>>>> +static __maybe_unused int as3645a_resume(struct device *dev) >>>>> +{ >>>>> + struct i2c_client *client = to_i2c_client(dev); >>>>> + struct as3645a *flash = i2c_get_clientdata(client); >>>>> + int rval; >>>>> + >>>>> + rval = as3645a_setup(flash); >>>>> + >>>> >>>> nitpicking: inconsistent coding style - there is no empty line before >>>> dev_dbg() in the as3645a_suspend(). >>> >>> Added one for as3645a_suspend() --- it should have been there. >>> >>>> >>>>> + dev_dbg(dev, "Resume %s\n", rval < 0 ? "fail" : "ok"); >>>>> + >>>>> + return rval; >>>>> +} >>> >>> ... >>> >>>>> +static int as3645a_led_class_setup(struct as3645a *flash) >>>>> +{ >>>>> + struct led_classdev *fled_cdev = &flash->fled.led_cdev; >>>>> + struct led_classdev *iled_cdev = &flash->iled_cdev; >>>>> + struct led_flash_setting *cfg; >>>>> + int rval; >>>>> + >>>>> + iled_cdev->name = "as3645a indicator"; >>>>> + iled_cdev->brightness_set_blocking = as3645a_set_indicator_brightness; >>>>> + iled_cdev->max_brightness = >>>>> + flash->cfg.indicator_max_ua / AS_INDICATOR_INTENSITY_STEP; >>>>> + >>>>> + rval = led_classdev_register(&flash->client->dev, iled_cdev); >>>>> + if (rval < 0) >>>>> + return rval; >>>>> + >>>>> + cfg = &flash->fled.brightness; >>>>> + cfg->min = AS_FLASH_INTENSITY_MIN; >>>>> + cfg->max = flash->cfg.flash_max_ua; >>>>> + cfg->step = AS_FLASH_INTENSITY_STEP; >>>>> + cfg->val = flash->cfg.flash_max_ua; >>>>> + >>>>> + cfg = &flash->fled.timeout; >>>>> + cfg->min = AS_FLASH_TIMEOUT_MIN; >>>>> + cfg->max = flash->cfg.flash_timeout_us; >>>>> + cfg->step = AS_FLASH_TIMEOUT_STEP; >>>>> + cfg->val = flash->cfg.flash_timeout_us; >>>>> + >>>>> + flash->fled.ops = &as3645a_led_flash_ops; >>>>> + >>>>> + fled_cdev->name = "as3645a flash"; >>>> >>>> LED class device name should be taken from label DT property, >>>> or DT node name if the former wasn't defined. >>>> >>>> Also LED device naming convention defines colon as a separator >>>> between name segments. >>> >>> Right. I'll fix that. >>> >>> I just realised I'm missing DT binding documentation for this device; I'll >>> add that, too. >>> >>> Is the preference to allow freely chosen node names for the LEDs? Now that >>> there's the label, too, this appears to be somewhat duplicated information. >> >> It depends on whether the sub-leds are identified by reg property. >> In this case usually common prefix is used followed by reg value, >> e.g. led@1, led@2 etc. > > Is there a device that would use this already? I checked common.txt and > I couldn't find a suggestion of this scheme there. There is no suitable suggestion in common.txt indeed, but it is used e.g. in: leds-mt6323.txt, leds-bcm6328.txt, leds-pm8058.txt. >> Otherwise prevailing scheme is e.g.: >> >> blue-power { >> ... >> label = "netxbig:blue:power"; >> } >> > -- Best regards, Jacek Anaszewski
Re: [PATCH v3 4/8] [media] s5p-jpeg: Don't use temporary structure in s5p_jpeg_buf_queue
Hi Thierry, On 06/27/2017 06:08 PM, Thierry Escande wrote: > If s5p_jpeg_parse_hdr() fails to parse the JPEG header, the passed > s5p_jpeg_q_data structure is not modify so there is no need to use a s/modify/modified/ > temporary structure and the field-by-field copy can be avoided. > > Signed-off-by: Thierry Escande > --- > drivers/media/platform/s5p-jpeg/jpeg-core.c | 23 --- > 1 file changed, 4 insertions(+), 19 deletions(-) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c > b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index df3e5ee..1769744 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -2500,9 +2500,9 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > > if (ctx->mode == S5P_JPEG_DECODE && > vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { > - struct s5p_jpeg_q_data tmp, *q_data; > + struct s5p_jpeg_q_data *q_data; > > - ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp, > + ctx->hdr_parsed = s5p_jpeg_parse_hdr(&ctx->out_q, >(unsigned long)vb2_plane_vaddr(vb, 0), >min((unsigned long)ctx->out_q.size, >vb2_get_plane_payload(vb, 0)), ctx); > @@ -2511,24 +2511,9 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) > return; > } > > - q_data = &ctx->out_q; > - q_data->w = tmp.w; > - q_data->h = tmp.h; > - q_data->sos = tmp.sos; > - memcpy(q_data->dht.marker, tmp.dht.marker, > -sizeof(tmp.dht.marker)); > - memcpy(q_data->dht.len, tmp.dht.len, sizeof(tmp.dht.len)); > - q_data->dht.n = tmp.dht.n; > - memcpy(q_data->dqt.marker, tmp.dqt.marker, > -sizeof(tmp.dqt.marker)); > - memcpy(q_data->dqt.len, tmp.dqt.len, sizeof(tmp.dqt.len)); > - q_data->dqt.n = tmp.dqt.n; > - q_data->sof = tmp.sof; > - q_data->sof_len = tmp.sof_len; > - > q_data = &ctx->cap_q; > - q_data->w = tmp.w; > - q_data->h = tmp.h; > + q_data->w = ctx->out_q.w; > + q_data->h = ctx->out_q.h; > > /* >* This call to jpeg_bound_align_image() takes care of width and > -- Best regards, Jacek Anaszewski
Re: [PATCH v3 0/8] [media] s5p-jpeg: Various fixes and improvements
Hi Thierry, For the whole series: Acked-by: Jacek Anaszewski Best regards, Jacek Anaszewski On 06/27/2017 06:08 PM, Thierry Escande wrote: > Hi, > > This series contains various fixes and improvements for the Samsung > s5p-jpeg driver. Most of these patches come from the Chromium v3.8 > kernel tree. > > In this v3: > - Remove codec reset patch (Not needed based on documentation and no > use case described in original patch commit message). > - Check for Exynos5420 variant in stream error handling patch. > - Add use case for resolution change event support in commit message. > - Move subsampling value decoding in a separate function. > - Check Exynos variant for 4:1:1 subsampling support. > > v2: > - Remove IOMMU support patch (mapping now created automatically for > single JPEG CODEC device). > - Remove "Change sclk_jpeg to 166MHz" patch (can be set through DT > properties). > - Remove support for multi-planar APIs (Not needed). > - Add comment regarding call to jpeg_bound_align_image() after qbuf. > - Remove unrelated code from resolution change event support patch. > > Thierry Escande (3): > [media] s5p-jpeg: Handle parsing error in s5p_jpeg_parse_hdr() > [media] s5p-jpeg: Don't use temporary structure in s5p_jpeg_buf_queue > [media] s5p-jpeg: Split s5p_jpeg_parse_hdr() > > Tony K Nadackal (3): > [media] s5p-jpeg: Call jpeg_bound_align_image after qbuf > [media] s5p-jpeg: Correct WARN_ON statement for checking subsampling > [media] s5p-jpeg: Decode 4:1:1 chroma subsampling format > > henryhsu (2): > [media] s5p-jpeg: Add support for resolution change event > [media] s5p-jpeg: Add stream error handling for Exynos5420 > > drivers/media/platform/s5p-jpeg/jpeg-core.c | 186 > +--- > drivers/media/platform/s5p-jpeg/jpeg-core.h | 7 ++ > 2 files changed, 148 insertions(+), 45 deletions(-) >
Re: [PATCH 2/2] v4l2-flash-led-class: Create separate sub-devices for indicators
*channel_torch, *channel_ind, *channel_flash; > @@ -543,12 +544,12 @@ static int gb_lights_light_v4l2_register(struct > gb_light *light) > channel_torch = get_channel_from_mode(light, GB_CHANNEL_MODE_TORCH); > if (channel_torch) > __gb_lights_channel_v4l2_config(&channel_torch->intensity_uA, > - &sd_cfg.torch_intensity); > + &sd_cfg.intensity); > > channel_ind = get_channel_from_mode(light, GB_CHANNEL_MODE_INDICATOR); > if (channel_ind) { > __gb_lights_channel_v4l2_config(&channel_ind->intensity_uA, > - &sd_cfg.indicator_intensity); > + &sd_cfg_ind.intensity); > iled = &channel_ind->fled.led_cdev; > } > > @@ -558,6 +559,8 @@ static int gb_lights_light_v4l2_register(struct gb_light > *light) > fled = &channel_flash->fled; > > snprintf(sd_cfg.dev_name, sizeof(sd_cfg.dev_name), "%s", light->name); > + snprintf(sd_cfg_ind.dev_name, sizeof(sd_cfg_ind.dev_name), > + "%s indicator", light->name); > > /* Set the possible values to faults, in our case all faults */ > sd_cfg.flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT | > @@ -566,21 +569,32 @@ static int gb_lights_light_v4l2_register(struct > gb_light *light) > LED_FAULT_UNDER_VOLTAGE | LED_FAULT_INPUT_VOLTAGE | > LED_FAULT_LED_OVER_TEMPERATURE; > > - light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, iled, > - &v4l2_flash_ops, &sd_cfg); > + light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, &v4l2_flash_ops, > + &sd_cfg); > if (IS_ERR_OR_NULL(light->v4l2_flash)) { > ret = PTR_ERR(light->v4l2_flash); > goto out_free; > } > > + if (channel_ind) { > + light->v4l2_flash_ind = > + v4l2_flash_indicator_init(dev, NULL, iled, &sd_cfg_ind); > + if (IS_ERR_OR_NULL(light->v4l2_flash_ind)) { > + ret = PTR_ERR(light->v4l2_flash_ind); > + goto out_free; > + } > + } > + > return ret; > > out_free: > + v4l2_flash_release(light->v4l2_flash); > return ret; > } > > static void gb_lights_light_v4l2_unregister(struct gb_light *light) > { > + v4l2_flash_release(light->v4l2_flash_ind); > v4l2_flash_release(light->v4l2_flash); > } > #else > diff --git a/include/media/v4l2-flash-led-class.h > b/include/media/v4l2-flash-led-class.h > index 54e31a805a88..c3f39992f3fa 100644 > --- a/include/media/v4l2-flash-led-class.h > +++ b/include/media/v4l2-flash-led-class.h > @@ -56,8 +56,7 @@ struct v4l2_flash_ops { > * struct v4l2_flash_config - V4L2 Flash sub-device initialization data > * @dev_name:the name of the media entity, > * unique in the system > - * @torch_intensity: constraints for the LED in torch mode > - * @indicator_intensity: constraints for the indicator LED > + * @intensity: non-flash strobe constraints for the LED > * @flash_faults:bitmask of flash faults that the LED flash class > * device can report; corresponding LED_FAULT* bit > * definitions are available in the header file > @@ -66,8 +65,7 @@ struct v4l2_flash_ops { > */ > struct v4l2_flash_config { > char dev_name[32]; > - struct led_flash_setting torch_intensity; > - struct led_flash_setting indicator_intensity; > + struct led_flash_setting intensity; > u32 flash_faults; > unsigned int has_external_strobe:1; > }; > @@ -110,8 +108,6 @@ static inline struct v4l2_flash > *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) > * @dev: flash device, e.g. an I2C device > * @fwn: fwnode_handle of the LED, may be NULL if the same as device's > * @fled_cdev: LED flash class device to wrap > - * @iled_cdev: LED flash class device representing indicator LED > associated > - * with fled_cdev, may be NULL > * @ops: V4L2 Flash device ops > * @config: initialization data for V4L2 Flash sub-device > * > @@ -124,9 +120,24 @@ static inline struct v4l2_flash > *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) > struct v4l2_flash *v4l2_flash_init( > struct device *dev, struct fwnode_handle *fwn,
Re: [RFC 05/19] leds: as3645a: Add LED flash class driver
Hi Sakari, Thanks for the update. My remarks from [0] related to LED class device naming apply also to this version of the patch. [0[ https://www.spinics.net/lists/linux-leds/msg08015.html Best regards, Jacek Anaszewski On 07/18/2017 09:03 PM, Sakari Ailus wrote: > From: Sakari Ailus > > Add a LED flash class driver for the as3654a flash controller. A V4L2 flash > driver for it already exists (drivers/media/i2c/as3645a.c), and this driver > is based on that. > > Signed-off-by: Sakari Ailus > --- > MAINTAINERS | 6 + > drivers/leds/Kconfig| 8 + > drivers/leds/Makefile | 1 + > drivers/leds/leds-as3645a.c | 742 > > 4 files changed, 757 insertions(+) > create mode 100644 drivers/leds/leds-as3645a.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 205d3977ac46..312be8939969 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -2106,6 +2106,12 @@ F: arch/arm64/ > F: Documentation/arm64/ > > AS3645A LED FLASH CONTROLLER DRIVER > +M: Sakari Ailus > +L: linux-l...@vger.kernel.org > +S: Maintained > +F: drivers/leds/leds-as3645a.c > + > +AS3645A LED FLASH CONTROLLER DRIVER > M: Laurent Pinchart > L: linux-media@vger.kernel.org > T: git git://linuxtv.org/media_tree.git > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > index 594b24d410c3..bad3a4098104 100644 > --- a/drivers/leds/Kconfig > +++ b/drivers/leds/Kconfig > @@ -58,6 +58,14 @@ config LEDS_AAT1290 > help >This option enables support for the LEDs on the AAT1290. > > +config LEDS_AS3645A > + tristate "AS3645A LED flash controller support" > + depends on I2C && LEDS_CLASS_FLASH > + help > + Enable LED flash class support for AS3645A LED flash > + controller. V4L2 flash API is provided as well if > + CONFIG_V4L2_FLASH_API is enabled. > + > config LEDS_BCM6328 > tristate "LED Support for Broadcom BCM6328" > depends on LEDS_CLASS > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile > index 909dae62ba05..7d7b26552923 100644 > --- a/drivers/leds/Makefile > +++ b/drivers/leds/Makefile > @@ -8,6 +8,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o > # LED Platform Drivers > obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o > obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o > +obj-$(CONFIG_LEDS_AS3645A) += leds-as3645a.o > obj-$(CONFIG_LEDS_BCM6328) += leds-bcm6328.o > obj-$(CONFIG_LEDS_BCM6358) += leds-bcm6358.o > obj-$(CONFIG_LEDS_BD2802)+= leds-bd2802.o > diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c > new file mode 100644 > index ..b1dc32a3c620 > --- /dev/null > +++ b/drivers/leds/leds-as3645a.c > @@ -0,0 +1,742 @@ > +/* > + * drivers/leds/leds-as3645a.c - AS3645A and LM3555 flash controllers driver > + * > + * Copyright (C) 2008-2011 Nokia Corporation > + * Copyright (c) 2011, 2017 Intel Corporation. > + * > + * Based on drivers/media/i2c/as3645a.c. > + * > + * Contact: Sakari Ailus > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License > + * version 2 as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but > + * WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#define AS_TIMER_US_TO_CODE(t) (((t) / 1000 - 100) / > 50) > +#define AS_TIMER_CODE_TO_US(c) ((50 * (c) + 100) * > 1000) > + > +/* Register definitions */ > + > +/* Read-only Design info register: Reset state: 0001 */ > +#define AS_DESIGN_INFO_REG 0x00 > +#define AS_DESIGN_INFO_FACTORY(x)(((x) >> 4)) > +#define AS_DESIGN_INFO_MODEL(x) ((x) & 0x0f) > + > +/* Read-only Version control register: Reset state: > + * for first engineering samples > + */ > +#define AS_VERSION_CONTROL_REG 0x01 > +#define AS_VERSION_CONTROL_RFU(x)(((x) >> 4)) > +#define AS_VERSION_CONTROL_VERSION(x)((x) & 0x0f) > + > +/* Read / Write (Indicator and timer register): Reset state: > */ > +#defin
Re: [PATCH 0/5] s5p-jpeg fixes
Hi Andrzej, Thanks for the patch set. On 08/08/2017 01:22 PM, Andrzej Pietrasiewicz wrote: > Hi All, > > This series contains a number of fixes to the s5p-jpeg driver. > > There are two patches from Tony K Nadackal, which got lost long time ago. > > @Thierry: > The patch changing the software reset routine you sent recently was > actually a resend of Tony's patch. I investigated the question why > this patch is needed. The encoder/decoder should be disabled as soon > as possible, in the interrupt service routine; please see the commit message. > I am resending Tony's patch again, with updated commit message. > Thank you for reminding about the patch in question! > > There are also three patches from me, please see appropriate commit > messages. > > Rebased onto Mauro's master. > > Andrzej Pietrasiewicz (3): > media: platform: s5p-jpeg: disable encoder/decoder in exynos4-like > hardware after use > media: platform: s5p-jpeg: fix number of components macro > media: platform: s5p-jpeg: directly use parsed subsampling on 5433 > > Tony K Nadackal (2): > media: platform: s5p-jpeg: Fix crash in jpeg isr due to multiple > interrupts. > media: platform: s5p-jpeg: Clear JPEG_CODEC_ON bits in sw reset > function > > drivers/media/platform/s5p-jpeg/jpeg-core.c | 8 +++- > drivers/media/platform/s5p-jpeg/jpeg-core.h | 1 + > drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 9 - > drivers/media/platform/s5p-jpeg/jpeg-regs.h | 2 +- > 4 files changed, 17 insertions(+), 3 deletions(-) > For the whole series: Reviewed-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski
Re: [PATCH 0/2] More s5p-jpeg fixes
Hi Andrzej, Thanks for the patches. On 08/11/2017 01:49 PM, Andrzej Pietrasiewicz wrote: > Hi All, > > The first patch in the series fixes decoding path, > the second patch fixes encoding path. Please see > appropriate commit messages. > > Andrzej Pietrasiewicz (2): > media: s5p-jpeg: don't overwrite result's "size" member > media: s5p-jpeg: set w/h when encoding > > drivers/media/platform/s5p-jpeg/jpeg-core.c | 10 +++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > Reviewed-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski
[PATCH] s5p-jpeg: Initialize vfd_decoder->vfl_dir field
This patch fixes regression introduced in the commit 5c77879ff9ab9e7 and caused by not initializing the vfl_dir field of the vfd_decoder instance of the struct video_device, after the field was introduced. It precluded calling the driver ioctls which require vfl_dir not to be equal to VFL_DIR_RX which is defined as 0 and uninitialized vfl_dir field is interpreted as such. In effect the unlikely() condition in the v4l_s_fmt function failed for the ioctls that expect is_tx to be false, which prevented the ioctl callbacks registered by the driver from being called. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park Cc: Hans Verkuil --- drivers/media/platform/s5p-jpeg/jpeg-core.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 88c5beb..1db4736 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1424,6 +1424,7 @@ static int s5p_jpeg_probe(struct platform_device *pdev) jpeg->vfd_decoder->release = video_device_release; jpeg->vfd_decoder->lock = &jpeg->lock; jpeg->vfd_decoder->v4l2_dev = &jpeg->v4l2_dev; + jpeg->vfd_decoder->vfl_dir = VFL_DIR_M2M; ret = video_register_device(jpeg->vfd_decoder, VFL_TYPE_GRABBER, -1); if (ret) { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 03/10] media framework: rename pads init function to media_entity_pads_init()
On 12/11/2015 02:34 PM, Mauro Carvalho Chehab wrote: With the MC next gen rework, what's left for media_entity_init() is to just initialize the PADs. However, certain devices, like a FLASH led/light doesn't have any input or output PAD. So, there's no reason why calling media_entity_init() would be mandatory. Also, despite its name, what this function actually does is to initialize the PADs data. So, rename it to media_entity_pads_init() in order to reflect that. The media entity actual init happens during entity register, at media_device_register_entity(). We should move init of num_links and num_backlinks to it. Signed-off-by: Mauro Carvalho Chehab [...] diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index 5c686a24712b..13d5a36bc5d8 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -651,7 +651,7 @@ struct v4l2_flash *v4l2_flash_init( sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; strlcpy(sd->name, config->dev_name, sizeof(sd->name)); - ret = media_entity_init(&sd->entity, 0, NULL); + ret = media_entity_pads_init(&sd->entity, 0, NULL); if (ret < 0) return ERR_PTR(ret); For this part: Acked-by: Jacek Anaszewski -- Best Regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 01/15] mediactl: Introduce v4l2_subdev structure
Hi Sakari, On 03/21/2016 12:39 AM, Sakari Ailus wrote: Hi Jacek, On Thu, Feb 18, 2016 at 03:15:32PM +0100, Jacek Anaszewski wrote: Hi Sakari, Thanks for the review. On 02/12/2016 01:42 PM, Sakari Ailus wrote: Hi Jacek, Thanks for continuing this work! And my apologies for reviewing only now... please see the comments below. Jacek Anaszewski wrote: Add struct v4l2_subdev - a representation of the v4l2 sub-device, related to the media entity. Add field 'sd', the pointer to the newly introduced structure, to the struct media_entity and move 'fd' property from struct media entity to struct v4l2_subdev. Avoid accessing sub-device file descriptor from libmediactl and make the v4l2_subdev_open capable of creating the v4l2_subdev if the 'sd' pointer is uninitialized. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c |4 -- utils/media-ctl/libv4l2subdev.c | 82 +++ utils/media-ctl/mediactl-priv.h |5 ++- utils/media-ctl/v4l2subdev.h| 38 ++ 4 files changed, 107 insertions(+), 22 deletions(-) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 4a82d24..7e98440 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -525,7 +525,6 @@ static int media_enum_entities(struct media_device *media) entity = &media->entities[media->entities_count]; memset(entity, 0, sizeof(*entity)); - entity->fd = -1; entity->info.id = id | MEDIA_ENT_ID_FLAG_NEXT; entity->media = media; @@ -719,8 +718,6 @@ void media_device_unref(struct media_device *media) free(entity->pads); free(entity->links); - if (entity->fd != -1) - close(entity->fd); } free(media->entities); @@ -747,7 +744,6 @@ int media_device_add_entity(struct media_device *media, entity = &media->entities[media->entities_count - 1]; memset(entity, 0, sizeof *entity); - entity->fd = -1; entity->media = media; strncpy(entity->devname, devnode, sizeof entity->devname); entity->devname[sizeof entity->devname - 1] = '\0'; diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 33c1ee6..3977ce5 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -39,13 +39,61 @@ #include "tools.h" #include "v4l2subdev.h" +int v4l2_subdev_create(struct media_entity *entity) +{ + if (entity->sd) + return 0; + + entity->sd = calloc(1, sizeof(*entity->sd)); + if (entity->sd == NULL) + return -ENOMEM; + + entity->sd->fd = -1; + + return 0; +} + +int v4l2_subdev_create_with_fd(struct media_entity *entity, int fd) +{ + int ret; + + if (entity->sd) + return -EEXIST; + + ret = v4l2_subdev_create(entity); + if (ret < 0) + return ret; + + entity->sd->fd = fd; + + return 0; +} + +void v4l2_subdev_release(struct media_entity *entity, bool close_fd) +{ + if (entity->sd == NULL) + return; + + if (close_fd) + v4l2_subdev_close(entity); + + free(entity->sd->v4l2_control_redir); + free(entity->sd); +} + int v4l2_subdev_open(struct media_entity *entity) { - if (entity->fd != -1) + int ret; + + ret = v4l2_subdev_create(entity); The current users of v4l2_subdev_open() in libv4l2subdev do not explicitly close the sub-devices they open; thus calling v4l2_subdev_create() here creates a memory leak. Currently in my use cases there is no memory leak since I assumed that the one who instantiates struct media_device should take care of releasing it properly. I added v4l2_subdev_open_pipeline() and v4l2_subdev_release_pipeline() API that is called on plugin init and close respectively. I'm referring to the use of the libv4l2subdev API as it's documented; the media-ctl test program which also serves as a good example on the API. Any sub-device IOCTL wrapper function will call v4l2_subdev_open() which stores the file descriptor returned by open(2) to struct media_entity.fd. v4l2_subdev_close() is not called explicitly. This is currently not required. The file handle is not leaked, as it is closed by media_device_unref() in libmediactl. This patch allocates memory for each sub-device in v4l2_subdev_create() which is in turn called from v4l2_subdev_open(). As the calls to v4l2_subdev_close() (which would release memory) are lacking, the memory is leaked. Probably it would be good to remove v4l2_subdev_open from v4l2_subdev_* prefixed API and return error if sd property of passed struct media_enti
Re: [PATCH 13/15] mediactl: Add media device ioctl API
Hi Sakari, On 03/21/2016 01:07 AM, Sakari Ailus wrote: Hi Jacek, On Thu, Feb 18, 2016 at 02:14:40PM +0100, Jacek Anaszewski wrote: Hi Sakari, On 02/18/2016 01:09 PM, Sakari Ailus wrote: Hi Jacek, On Mon, Feb 15, 2016 at 02:06:06PM +0100, Jacek Anaszewski wrote: Hi Sakari, Thanks for the review. On 02/15/2016 01:41 PM, Sakari Ailus wrote: Hi Jacek, Jacek Anaszewski wrote: Ioctls executed on complex media devices need special handling. For instance some ioctls need to be targeted for specific sub-devices, depending on the media device configuration. The APIs being introduced address such requirements. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/Makefile.am |2 +- utils/media-ctl/libv4l2media_ioctl.c | 404 ++ utils/media-ctl/libv4l2media_ioctl.h | 48 3 files changed, 453 insertions(+), 1 deletion(-) create mode 100644 utils/media-ctl/libv4l2media_ioctl.c create mode 100644 utils/media-ctl/libv4l2media_ioctl.h diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am index 3e883e0..7f18624 100644 --- a/utils/media-ctl/Makefile.am +++ b/utils/media-ctl/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la -libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h +libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libv4l2media_ioctl.c libv4l2media_ioctl.h libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS) libmediactl_la_LDFLAGS = -static $(LIBUDEV_LIBS) diff --git a/utils/media-ctl/libv4l2media_ioctl.c b/utils/media-ctl/libv4l2media_ioctl.c new file mode 100644 index 000..b186121 --- /dev/null +++ b/utils/media-ctl/libv4l2media_ioctl.c @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Author: Jacek Anaszewski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#include +#include +#include +#include + +#include + +#include "libv4l2media_ioctl.h" +#include "mediactl-priv.h" +#include "mediactl.h" +#include "v4l2subdev.h" + +#define VIDIOC_CTRL(type) \ + ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" : \ + "VIDIOC_G_CTRL") + +#define VIDIOC_EXT_CTRL(type) \ + ((type) == VIDIOC_S_EXT_CTRLS ? \ + "VIDIOC_S_EXT_CTRLS" : \ +((type) == VIDIOC_G_EXT_CTRLS ?\ + "VIDIOC_G_EXT_CTRLS" :\ + "VIDIOC_TRY_EXT_CTRLS")) + +#define SYS_IOCTL(fd, cmd, arg) \ + syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg)) + + +int media_ioctl_ctrl(struct media_device *media, int request, unsigned int request OK. +struct v4l2_control *arg) I wonder if it'd make sense to always use v4l2_ext_control instead. You can't access 64-bit integer controls with VIDIOC_S_CTRL for instance. This function is meant to handle VIDIOC_S_CTRL/VIDIOC_G_CTRL ioctls. For ext ctrls there is media_ioctl_ext_ctrl(). Is there any reason not to use extended control always? In other words, do we have a driver that does support Media controller but does not support extended controls? Shouldn't we support non-extended controls for backward compatibility reasons? I am not aware of the policy in this matter. To put it bluntly, supporting the non-extended controls in this use is waste of time IMHO. OK, I'll drop the non-ext controls related API then. As this is a user space library, I'd probably add a function to handle S/G/TRY control each. There is media_ioctl_ext_ctrl() that handles VIDIOC_S_EXT_CTRLS, VIDIOC_G_EXT_CTRLS and VIDIOC_TRY_EXT_CTRLS. Have you considered binding the control to a video node rather than a media device? We have many sensors on current media devices already, and e.g. exposure time control can be found in multiple sub-devices. Doesn't v4l2-ctrl-redir config entry address that? How does it work if you have, say, two video nodes where you can capture images from a different sensor? I.e. your media graph could look like this: sensor0 -> CSI-2 0 -> video0 sensor1 -> CSI-2 1 -> video1 Exemplary conf
Re: [PATCH 13/15] mediactl: Add media device ioctl API
On 03/23/2016 05:24 PM, Sakari Ailus wrote: Hi Jacek, On Tue, Mar 22, 2016 at 10:36:05AM +0100, Jacek Anaszewski wrote: Hi Sakari, On 03/21/2016 01:07 AM, Sakari Ailus wrote: Hi Jacek, On Thu, Feb 18, 2016 at 02:14:40PM +0100, Jacek Anaszewski wrote: Hi Sakari, On 02/18/2016 01:09 PM, Sakari Ailus wrote: Hi Jacek, On Mon, Feb 15, 2016 at 02:06:06PM +0100, Jacek Anaszewski wrote: Hi Sakari, Thanks for the review. On 02/15/2016 01:41 PM, Sakari Ailus wrote: Hi Jacek, Jacek Anaszewski wrote: Ioctls executed on complex media devices need special handling. For instance some ioctls need to be targeted for specific sub-devices, depending on the media device configuration. The APIs being introduced address such requirements. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/Makefile.am |2 +- utils/media-ctl/libv4l2media_ioctl.c | 404 ++ utils/media-ctl/libv4l2media_ioctl.h | 48 3 files changed, 453 insertions(+), 1 deletion(-) create mode 100644 utils/media-ctl/libv4l2media_ioctl.c create mode 100644 utils/media-ctl/libv4l2media_ioctl.h diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am index 3e883e0..7f18624 100644 --- a/utils/media-ctl/Makefile.am +++ b/utils/media-ctl/Makefile.am @@ -1,6 +1,6 @@ noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la -libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h +libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libv4l2media_ioctl.c libv4l2media_ioctl.h libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS) libmediactl_la_LDFLAGS = -static $(LIBUDEV_LIBS) diff --git a/utils/media-ctl/libv4l2media_ioctl.c b/utils/media-ctl/libv4l2media_ioctl.c new file mode 100644 index 000..b186121 --- /dev/null +++ b/utils/media-ctl/libv4l2media_ioctl.c @@ -0,0 +1,404 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Author: Jacek Anaszewski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#include +#include +#include +#include + +#include + +#include "libv4l2media_ioctl.h" +#include "mediactl-priv.h" +#include "mediactl.h" +#include "v4l2subdev.h" + +#define VIDIOC_CTRL(type) \ + ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" : \ + "VIDIOC_G_CTRL") + +#define VIDIOC_EXT_CTRL(type) \ + ((type) == VIDIOC_S_EXT_CTRLS ? \ + "VIDIOC_S_EXT_CTRLS" : \ +((type) == VIDIOC_G_EXT_CTRLS ?\ + "VIDIOC_G_EXT_CTRLS" :\ + "VIDIOC_TRY_EXT_CTRLS")) + +#define SYS_IOCTL(fd, cmd, arg) \ + syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg)) + + +int media_ioctl_ctrl(struct media_device *media, int request, unsigned int request OK. +struct v4l2_control *arg) I wonder if it'd make sense to always use v4l2_ext_control instead. You can't access 64-bit integer controls with VIDIOC_S_CTRL for instance. This function is meant to handle VIDIOC_S_CTRL/VIDIOC_G_CTRL ioctls. For ext ctrls there is media_ioctl_ext_ctrl(). Is there any reason not to use extended control always? In other words, do we have a driver that does support Media controller but does not support extended controls? Shouldn't we support non-extended controls for backward compatibility reasons? I am not aware of the policy in this matter. To put it bluntly, supporting the non-extended controls in this use is waste of time IMHO. OK, I'll drop the non-ext controls related API then. As this is a user space library, I'd probably add a function to handle S/G/TRY control each. There is media_ioctl_ext_ctrl() that handles VIDIOC_S_EXT_CTRLS, VIDIOC_G_EXT_CTRLS and VIDIOC_TRY_EXT_CTRLS. Have you considered binding the control to a video node rather than a media device? We have many sensors on current media devices already, and e.g. exposure time control can be found in multiple sub-devices. Doesn't v4l2-ctrl-redir config entry address that? How does it work if you have, say, two video nodes where you can capture images from a different sensor? I.e. your media graph could look like thi
Re: [PATCH] [media] s5p-jpeg: fix recursive spinlock acquisition
Hi Alexandre, Thanks for the patch. On 04/25/2017 08:19 AM, Alexandre Courbot wrote: > v4l2_m2m_job_finish(), which is called from the interrupt handler with > slock acquired, can call the device_run() hook immediately if another > context was in the queue. This hook also acquires slock, resulting in > a deadlock for this scenario. > > Fix this by releasing slock right before calling v4l2_m2m_job_finish(). > This is safe to do as the state of the hardware cannot change before > v4l2_m2m_job_finish() is called anyway. > > Signed-off-by: Alexandre Courbot > --- > drivers/media/platform/s5p-jpeg/jpeg-core.c | 12 +--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c > b/drivers/media/platform/s5p-jpeg/jpeg-core.c > index 52dc7941db65..223b4379929e 100644 > --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c > +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c > @@ -2642,13 +2642,13 @@ static irqreturn_t s5p_jpeg_irq(int irq, void *dev_id) > if (curr_ctx->mode == S5P_JPEG_ENCODE) > vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload_size); > v4l2_m2m_buf_done(dst_buf, state); > - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); > > curr_ctx->subsampling = s5p_jpeg_get_subsampling_mode(jpeg->regs); > spin_unlock(&jpeg->slock); > > s5p_jpeg_clear_int(jpeg->regs); > > + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); > return IRQ_HANDLED; > } > > @@ -2707,11 +2707,12 @@ static irqreturn_t exynos4_jpeg_irq(int irq, void > *priv) > v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_ERROR); > } > > - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); > if (jpeg->variant->version == SJPEG_EXYNOS4) > curr_ctx->subsampling = exynos4_jpeg_get_frame_fmt(jpeg->regs); > > spin_unlock(&jpeg->slock); > + > + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); > return IRQ_HANDLED; > } > > @@ -2770,10 +2771,15 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, void > *dev_id) > if (curr_ctx->mode == S5P_JPEG_ENCODE) > vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload_size); > v4l2_m2m_buf_done(dst_buf, state); > - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); > > curr_ctx->subsampling = > exynos3250_jpeg_get_subsampling_mode(jpeg->regs); > + > + spin_unlock(&jpeg->slock); > + > + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); > + return IRQ_HANDLED; > + > exit_unlock: > spin_unlock(&jpeg->slock); > return IRQ_HANDLED; > Acked-by: Jacek Anaszewski Just out of curiosity - could you share how you discovered the problem - by some static checkers or trying to use the driver? -- Best regards, Jacek Anaszewski
Re: [PATCH] [media] s5p-jpeg: fix recursive spinlock acquisition
On 04/26/2017 04:54 AM, Alexandre Courbot wrote: > On Wed, Apr 26, 2017 at 4:15 AM, Jacek Anaszewski > wrote: >> Hi Alexandre, >> >> Thanks for the patch. >> >> On 04/25/2017 08:19 AM, Alexandre Courbot wrote: >>> v4l2_m2m_job_finish(), which is called from the interrupt handler with >>> slock acquired, can call the device_run() hook immediately if another >>> context was in the queue. This hook also acquires slock, resulting in >>> a deadlock for this scenario. >>> >>> Fix this by releasing slock right before calling v4l2_m2m_job_finish(). >>> This is safe to do as the state of the hardware cannot change before >>> v4l2_m2m_job_finish() is called anyway. >>> >>> Signed-off-by: Alexandre Courbot >>> --- >>> drivers/media/platform/s5p-jpeg/jpeg-core.c | 12 +--- >>> 1 file changed, 9 insertions(+), 3 deletions(-) >>> >>> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c >>> b/drivers/media/platform/s5p-jpeg/jpeg-core.c >>> index 52dc7941db65..223b4379929e 100644 >>> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c >>> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c >>> @@ -2642,13 +2642,13 @@ static irqreturn_t s5p_jpeg_irq(int irq, void >>> *dev_id) >>> if (curr_ctx->mode == S5P_JPEG_ENCODE) >>> vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload_size); >>> v4l2_m2m_buf_done(dst_buf, state); >>> - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>> >>> curr_ctx->subsampling = s5p_jpeg_get_subsampling_mode(jpeg->regs); >>> spin_unlock(&jpeg->slock); >>> >>> s5p_jpeg_clear_int(jpeg->regs); >>> >>> + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>> return IRQ_HANDLED; >>> } >>> >>> @@ -2707,11 +2707,12 @@ static irqreturn_t exynos4_jpeg_irq(int irq, void >>> *priv) >>> v4l2_m2m_buf_done(dst_vb, VB2_BUF_STATE_ERROR); >>> } >>> >>> - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>> if (jpeg->variant->version == SJPEG_EXYNOS4) >>> curr_ctx->subsampling = >>> exynos4_jpeg_get_frame_fmt(jpeg->regs); >>> >>> spin_unlock(&jpeg->slock); >>> + >>> + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>> return IRQ_HANDLED; >>> } >>> >>> @@ -2770,10 +2771,15 @@ static irqreturn_t exynos3250_jpeg_irq(int irq, >>> void *dev_id) >>> if (curr_ctx->mode == S5P_JPEG_ENCODE) >>> vb2_set_plane_payload(&dst_buf->vb2_buf, 0, payload_size); >>> v4l2_m2m_buf_done(dst_buf, state); >>> - v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>> >>> curr_ctx->subsampling = >>> exynos3250_jpeg_get_subsampling_mode(jpeg->regs); >>> + >>> + spin_unlock(&jpeg->slock); >>> + >>> + v4l2_m2m_job_finish(jpeg->m2m_dev, curr_ctx->fh.m2m_ctx); >>> + return IRQ_HANDLED; >>> + >>> exit_unlock: >>> spin_unlock(&jpeg->slock); >>> return IRQ_HANDLED; >>> >> >> Acked-by: Jacek Anaszewski >> >> Just out of curiosity - could you share how you discovered the problem - >> by some static checkers or trying to use the driver? > > We discovered this issue after adding a new unit test for the jpeg > codec in Chromium OS: > > https://bugs.chromium.org/p/chromium/issues/detail?id=705971 > >>From what I understand the test spawns different processes that access > the codec device concurrently, creating the situation leading to the > bug. Thanks for the explanation. Nice fix. > On a slightly related note, I was thinking whether it would make sense > to move the call to v4l2_m2m_job_finish() (and maybe other parts of > the current interrupt handler) into a worker or a threaded interrupt > handler so as to reduce the time we spend with interrupts disabled. > Can I have your input on this idea? Right, all remaining drivers call it from workers. Feel free to submit a patch. -- Best regards, Jacek Anaszewski
Re: [PATCH 12/12] leds: Only descend into leds directory when CONFIG_NEW_LEDS is set
Hi Andrew, Thanks for the patch. Please address the issue [1] raised by test bot and resubmit. Thanks, Jacek Anaszewski [1] https://lkml.org/lkml/2016/6/13/1091 On 06/13/2016 10:02 PM, Andrew F. Davis wrote: When CONFIG_NEW_LEDS is not set make will still descend into the leds directory but nothing will be built. This produces unneeded build artifacts and messages in addition to slowing the build. Fix this here. Signed-off-by: Andrew F. Davis --- drivers/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/Makefile b/drivers/Makefile index 567e32c..fa514d5 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -127,7 +127,7 @@ obj-$(CONFIG_CPU_FREQ) += cpufreq/ obj-$(CONFIG_CPU_IDLE)+= cpuidle/ obj-$(CONFIG_MMC) += mmc/ obj-$(CONFIG_MEMSTICK)+= memstick/ -obj-y += leds/ +obj-$(CONFIG_NEW_LEDS) += leds/ obj-$(CONFIG_INFINIBAND) += infiniband/ obj-$(CONFIG_SGI_SN) += sn/ obj-y += firmware/ -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/6] [media] s5p-jpeg: only fill driver's name in capabilities driver field
Hi Javier, On 06/16/2016 11:40 PM, Javier Martinez Canillas wrote: The driver fills in both the struct v4l2_capability driver and card fields the same values, that is the driver's name plus the information if the dev is a decoder or an encoder. But the driver field has a fixed length of 16 bytes so the filled data is truncated: Driver Info (not using libv4l2): Driver name : s5p-jpeg decode Card type : s5p-jpeg decoder Bus info : platform:11f5.jpeg Driver version: 4.7.0 Also, this field should only contain the driver's name so use just that. The information if the device is a decoder or an encoder is in the card type field anyways. Signed-off-by: Javier Martinez Canillas --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index e3ff3d4bd72e..f9fb52a53e79 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1246,12 +1246,12 @@ static int s5p_jpeg_querycap(struct file *file, void *priv, struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); if (ctx->mode == S5P_JPEG_ENCODE) { - strlcpy(cap->driver, S5P_JPEG_M2M_NAME " encoder", + strlcpy(cap->driver, S5P_JPEG_M2M_NAME, sizeof(cap->driver)); strlcpy(cap->card, S5P_JPEG_M2M_NAME " encoder", sizeof(cap->card)); } else { - strlcpy(cap->driver, S5P_JPEG_M2M_NAME " decoder", + strlcpy(cap->driver, S5P_JPEG_M2M_NAME, sizeof(cap->driver)); strlcpy(cap->card, S5P_JPEG_M2M_NAME " decoder", sizeof(cap->card)); Acked-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/6] [media] s5p-jpeg: set capablity bus_info as required by VIDIOC_QUERYCAP
Hi Javier, On 06/16/2016 11:40 PM, Javier Martinez Canillas wrote: The driver doesn't set the struct v4l2_capability cap_info field so the v4l2-compliance tool reports the following errors for VIDIOC_QUERYCAP: Required ioctls: VIDIOC_QUERYCAP returned 0 (Success) fail: v4l2-compliance.cpp(304): string empty fail: v4l2-compliance.cpp(528): check_ustring(vcap.bus_info, sizeof(vcap.bus_info)) test VIDIOC_QUERYCAP: FAIL This patch fixes by setting the field in VIDIOC_QUERYCAP ioctl handler: Required ioctls: VIDIOC_QUERYCAP returned 0 (Success) test VIDIOC_QUERYCAP: OK Signed-off-by: Javier Martinez Canillas --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 17bc94092864..e3ff3d4bd72e 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1256,7 +1256,8 @@ static int s5p_jpeg_querycap(struct file *file, void *priv, strlcpy(cap->card, S5P_JPEG_M2M_NAME " decoder", sizeof(cap->card)); } - cap->bus_info[0] = 0; + snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s", +dev_name(ctx->jpeg->dev)); cap->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M; cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS; return 0; Acked-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 12/12] leds: Only descend into leds directory when CONFIG_NEW_LEDS is set
On 06/18/2016 12:46 AM, Andrew F. Davis wrote: On 06/15/2016 01:48 AM, Jacek Anaszewski wrote: Hi Andrew, Thanks for the patch. Please address the issue [1] raised by test bot and resubmit. Thanks, Jacek Anaszewski [1] https://lkml.org/lkml/2016/6/13/1091 It looks like some systems use 'gpio_led_register_device' to make an in-memory copy of their LED device table so the original can be removed as .init.rodata. This doesn't necessarily depend on the LED subsystem but it kind of seems useless when the rest of the subsystem is disabled. One solution could be to use a dummy 'gpio_led_register_device' when the subsystem is not enabled. It sounds good. Please add a no-op version of gpio_led_register_device() to include/leds.h, in a separate patch. Thanks, Jacek Anaszewski Another is just to remove the five or so uses of 'gpio_led_register_device' and have those systems register LED device tables like other systems do. If nether of these are acceptable then this patch can be dropped from this series for now. Thanks, Andrew On 06/13/2016 10:02 PM, Andrew F. Davis wrote: When CONFIG_NEW_LEDS is not set make will still descend into the leds directory but nothing will be built. This produces unneeded build artifacts and messages in addition to slowing the build. Fix this here. Signed-off-by: Andrew F. Davis --- drivers/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/Makefile b/drivers/Makefile index 567e32c..fa514d5 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -127,7 +127,7 @@ obj-$(CONFIG_CPU_FREQ)+= cpufreq/ obj-$(CONFIG_CPU_IDLE)+= cpuidle/ obj-$(CONFIG_MMC)+= mmc/ obj-$(CONFIG_MEMSTICK)+= memstick/ -obj-y+= leds/ +obj-$(CONFIG_NEW_LEDS)+= leds/ obj-$(CONFIG_INFINIBAND)+= infiniband/ obj-$(CONFIG_SGI_SN)+= sn/ obj-y+= firmware/ -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] leds: Add no-op gpio_led_register_device when LED subsystem is disabled
Hi Andrew, This patch doesn't apply, please rebase onto recent LED tree. On 06/21/2016 12:13 AM, Andrew F. Davis wrote: Some systems use 'gpio_led_register_device' to make an in-memory copy of their LED device table so the original can be removed as .init.rodata. When the LED subsystem is not enabled source in the led directory is not built and so this function may be undefined. Fix this here. Signed-off-by: Andrew F. Davis --- include/linux/leds.h | 8 1 file changed, 8 insertions(+) diff --git a/include/linux/leds.h b/include/linux/leds.h index d2b1306..a4a3da6 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -386,8 +386,16 @@ struct gpio_led_platform_data { unsigned long *delay_off); Currently there is some stuff here, and in fact it has been for a long time. Patch "[PATCH 12/12] leds: Only descend into leds directory when CONFIG_NEW_LEDS is set" also doesn't apply. What repository are you using? }; +#ifdef CONFIG_NEW_LEDS struct platform_device *gpio_led_register_device( int id, const struct gpio_led_platform_data *pdata); +#else +static inline struct platform_device *gpio_led_register_device( + int id, const struct gpio_led_platform_data *pdata) +{ + return 0; +} +#endif enum cpu_led_event { CPU_LED_IDLE_START, /* CPU enters idle */ -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] leds: Add no-op gpio_led_register_device when LED subsystem is disabled
On 06/21/2016 01:48 PM, Andrew F. Davis wrote: On 06/21/2016 02:09 AM, Jacek Anaszewski wrote: Hi Andrew, This patch doesn't apply, please rebase onto recent LED tree. On 06/21/2016 12:13 AM, Andrew F. Davis wrote: Some systems use 'gpio_led_register_device' to make an in-memory copy of their LED device table so the original can be removed as .init.rodata. When the LED subsystem is not enabled source in the led directory is not built and so this function may be undefined. Fix this here. Signed-off-by: Andrew F. Davis --- include/linux/leds.h | 8 1 file changed, 8 insertions(+) diff --git a/include/linux/leds.h b/include/linux/leds.h index d2b1306..a4a3da6 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -386,8 +386,16 @@ struct gpio_led_platform_data { unsigned long *delay_off); Currently there is some stuff here, and in fact it has been for a long time. Patch "[PATCH 12/12] leds: Only descend into leds directory when CONFIG_NEW_LEDS is set" also doesn't apply. What repository are you using? v4.7-rc4, it may not apply due to the surrounding lines being changed in the other patches which may not be applied to your tree. It is a single line change per patch so hopefully the merge conflict resolutions will be trivial. A better solution could have been getting an ack from each maintainer and having someone pull the whole series into one tree, but parts have already been picked so it may be a little late for that. OK, I resolved the issues and applied, thanks. }; +#ifdef CONFIG_NEW_LEDS struct platform_device *gpio_led_register_device( int id, const struct gpio_led_platform_data *pdata); +#else +static inline struct platform_device *gpio_led_register_device( + int id, const struct gpio_led_platform_data *pdata) +{ + return 0; +} +#endif enum cpu_led_event { CPU_LED_IDLE_START, /* CPU enters idle */ -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 5/6] Documentation: bindings: add documentation for ir-spi device driver
Hi Andi, Only DT bindings of LED class drivers should be placed in Documentation/devicetree/bindings/leds. Please move it to the media bindings. Thanks, Jacek Anaszewski On 11/02/2016 11:40 AM, Andi Shyti wrote: Document the ir-spi driver's binding which is a IR led driven through the SPI line. Signed-off-by: Andi Shyti --- .../devicetree/bindings/leds/spi-ir-led.txt| 29 ++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/spi-ir-led.txt diff --git a/Documentation/devicetree/bindings/leds/spi-ir-led.txt b/Documentation/devicetree/bindings/leds/spi-ir-led.txt new file mode 100644 index 000..896b699 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/spi-ir-led.txt @@ -0,0 +1,29 @@ +Device tree bindings for IR LED connected through SPI bus which is used as +remote controller. + +The IR LED switch is connected to the MOSI line of the SPI device and the data +are delivered thourgh that. + +Required properties: + - compatible: should be "ir-spi-led". + +Optional properties: + - duty-cycle: 8 bit balue that represents the percentage of one period + in which the signal is active. It can be 50, 60, 70, 75, 80 or 90. + - led-active-low: boolean value that specifies whether the output is + negated with a NOT gate. + - power-supply: specifies the power source. It can either be a regulator + or a gpio which enables a regulator, i.e. a regulator-fixed as + described in + Documentation/devicetree/bindings/regulator/fixed-regulator.txt + +Example: + + irled@0 { + compatible = "ir-spi-led"; + reg = <0x0>; + spi-max-frequency = <500>; + power-supply = <&vdd_led>; + led-active-low; + duty-cycle = /bits/ 8 <60>; + }; -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 5/6] Documentation: bindings: add documentation for ir-spi device driver
On 11/03/2016 11:10 AM, Andi Shyti wrote: Hi Jacek, Only DT bindings of LED class drivers should be placed in Documentation/devicetree/bindings/leds. Please move it to the media bindings. that's where I placed it first, but Rob asked me to put it in the LED directory and Cc the LED mailining list. That's the discussion of the version 2: https://lkml.org/lkml/2016/9/12/380 Rob, Jacek, could you please agree where I can put the binding? I'm not sure if this is a good approach. I've noticed also that backlight bindings have been moved to leds, whereas they don't look similarly. We have common.txt LED bindings, that all LED class drivers' bindings have to follow. Neither backlight bindings nor these ones do that, which introduces some mess. Eventually adding a sub-directory, e.g. remote_control could make it somehow logically justified, but still - shouldn't bindings be placed in the documentation directory related to the subsystem of the driver they are predestined to? -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4l-utils v7 0/7] Add a plugin for Exynos4 camera
Hi Hans, On 11/03/2016 12:51 PM, Hans Verkuil wrote: Hi all, Is there anything that blocks me from merging this? This plugin work has been ongoing for years and unless there are serious objections I propose that this is merged. Jacek, is there anything missing that would prevent merging this? There were issues raised by Sakari during last review, related to the way how v4l2 control bindings are defined. That discussion wasn't finished, so I stayed by my approach. Other than that - I've tested it and it works fine both with GStreamer and my test app. Best regards, Jacek Anaszewski On 12/10/16 16:35, Jacek Anaszewski wrote: This is a seventh version of the patch series adding a plugin for the Exynos4 camera. Last version [0] of the patch set was posted in January. The plugin doesn't link against libmediactl, but has its sources compiled in. Currently utils are built after the plugins, but libv4l-exynos4-camera plugin depends on the utils. In order to link the plugin against libmediactl the build system would have to be modified. Changes from v6: - close v4l2 sub-devices on media device release - moved non-generic code from libmediactl to the plugin - resigned from adding libmedia_ioctl library and moved all its code to the plugin, since it depended on pipeline representation, which was not generic for all possible media device topologies - used media_get_info()->name instead of adding media_entity_get_name - renamed media_get_backlinks_by_entity() to media_entity_get_backlinks(() - moved pipeline from struct media_device to the plugin - changed the way of associating video device file descriptor with media device - switched to using auto-generated media-bus-format-names.h header file - renamed v4l2-ctrl-redir config entry name to v4l2-ctrl-binding Changes from v5: - fixed and tested use cases with S5K6A3 sensor and FIMC-IS-ISP - added conversion "colorspace id to string" Changes from v4: - removed some redundant functions for traversing media device graph and switched over to using existing ones - avoided accessing struct v4l2_subdev from libmediactl - applied various improvements Changes from v3: - added struct v4l2_subdev and put entity fd and information about supported controls to it - improved functions for negotiating and setting pipeline format by using available libv4lsubdev API - applied minor improvements and cleanups Changes from v2: - switched to using mediatext library for parsing the media device configuration - extended libmediactl - switched to using libmediactl Changes from v1: - removed redundant mbus code negotiation - split the parser, media device helpers and ioctl wrappers to the separate modules - added mechanism for querying extended controls - applied various fixes and modifications The plugin was tested on v4.8-rc2 (exynos4-is driver doesn't proble properly with current master branch of linux-media.git) with patches fixing several issues for Exynos4 camera: [1], [2], [3]. The plugin expects a configuration file: /var/lib/libv4l/exynos4_capture_conf Exemplary configuration file for pipeline with sensor S5C73M3 (rear camera): == link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1] v4l2-ctrl-binding 0x0098091f -> "fimc.0.capture" v4l2-ctrl-binding 0x00980902 -> "S5C73M3" v4l2-ctrl-binding 0x00980922 -> "fimc.0.capture" v4l2-ctrl-binding 0x009a0914 -> "S5C73M3" == With this settings the plugin can be tested on the exynos4412-trats2 board using following gstreamer pipeline: gst-launch-1.0 v4l2src device=/dev/video1 extra-controls="c,rotate=90,color_effects=2" ! video/x-raw,width=960,height=720 ! fbdevsink Exemplary configuration file for pipeline with sensor S5K6A3 (front camera): == link-conf "s5p-mipi-csis.1":1 -> "FIMC-LITE.1":0 [1] link-conf "FIMC-LITE.1":2 -> "FIMC-IS-ISP":0 [1] link-conf "FIMC-IS-ISP":1 -> "FIMC.0":1 [1] ====== gst-launch-1.0 v4l2src device=/dev/video1 extra-controls="c,rotate=270,color_effects=2,horizontal_flip=1" ! video/x-raw,width=960,height=920 ! fbdevsink Best Regards, Jacek Anaszewski [0] http://www.spinics.net/lists/linux-media/msg96510.html [1] https://patchwork.kernel.org/patch/9335197/ [2] https://patchwork.kernel.org/patch/9270985/ [3] https://patchwork.kernel.org/patch/9308923/ [4] https://patchwork.kernel.org/patch/9335273/ Jacek Anaszewski (7): mediactl: Add support for v4l2-ctrl-binding config mediatext: Add library mediactl: Add media_en
Re: [PATCH v3 5/6] Documentation: bindings: add documentation for ir-spi device driver
On 11/09/2016 07:26 PM, Rob Herring wrote: On Thu, Nov 03, 2016 at 11:39:21AM +0100, Jacek Anaszewski wrote: On 11/03/2016 11:10 AM, Andi Shyti wrote: Hi Jacek, Only DT bindings of LED class drivers should be placed in Documentation/devicetree/bindings/leds. Please move it to the media bindings. that's where I placed it first, but Rob asked me to put it in the LED directory and Cc the LED mailining list. That's the discussion of the version 2: https://lkml.org/lkml/2016/9/12/380 Rob, Jacek, could you please agree where I can put the binding? I'm not sure if this is a good approach. I've noticed also that backlight bindings have been moved to leds, whereas they don't look similarly. We have common.txt LED bindings, that all LED class drivers' bindings have to follow. Neither backlight bindings nor these ones do that, which introduces some mess. And there are probably LED bindings that don't follow common.txt either. Eventually adding a sub-directory, e.g. remote_control could make it somehow logically justified, but still - shouldn't bindings be placed in the documentation directory related to the subsystem of the driver they are predestined to? No. While binding directories often mirror the driver directories, they are not the same. Bindings are grouped by types of h/w and IR LEDs are a type of LED. If you prefer a sub-dir, that is fine with me. Fine. So how about sub-dir "ir" ? -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4l-utils v7 0/7] Add a plugin for Exynos4 camera
On 11/23/2016 10:51 PM, Mauro Carvalho Chehab wrote: Em Thu, 03 Nov 2016 13:13:12 +0100 Jacek Anaszewski escreveu: Hi Hans, On 11/03/2016 12:51 PM, Hans Verkuil wrote: Hi all, Is there anything that blocks me from merging this? This plugin work has been ongoing for years and unless there are serious objections I propose that this is merged. Jacek, is there anything missing that would prevent merging this? There were issues raised by Sakari during last review, related to the way how v4l2 control bindings are defined. That discussion wasn't finished, so I stayed by my approach. Are those things something that could be fixed later without breaking binary apps? If not, then perhaps it is time to merge this. They are related to the format of configuration file being introduced by this patch set, so there are no binary apps depending on it. Few days ago I had a discussion with Sakari on IRC, and he pointed me to his patch set adding an extended version of his mediatext library RFC [0], the first version of which I included to my patch set, and extended a bit. A decision should be made if I should adapt my API to the mediatext RFC. RFC is not a stable ground though. [0] https://www.spinics.net/lists/linux-media/msg103242.html Other than that - I've tested it and it works fine both with GStreamer and my test app. Best regards, Jacek Anaszewski On 12/10/16 16:35, Jacek Anaszewski wrote: This is a seventh version of the patch series adding a plugin for the Exynos4 camera. Last version [0] of the patch set was posted in January. The plugin doesn't link against libmediactl, but has its sources compiled in. Currently utils are built after the plugins, but libv4l-exynos4-camera plugin depends on the utils. In order to link the plugin against libmediactl the build system would have to be modified. Changes from v6: - close v4l2 sub-devices on media device release - moved non-generic code from libmediactl to the plugin - resigned from adding libmedia_ioctl library and moved all its code to the plugin, since it depended on pipeline representation, which was not generic for all possible media device topologies - used media_get_info()->name instead of adding media_entity_get_name - renamed media_get_backlinks_by_entity() to media_entity_get_backlinks(() - moved pipeline from struct media_device to the plugin - changed the way of associating video device file descriptor with media device - switched to using auto-generated media-bus-format-names.h header file - renamed v4l2-ctrl-redir config entry name to v4l2-ctrl-binding Changes from v5: - fixed and tested use cases with S5K6A3 sensor and FIMC-IS-ISP - added conversion "colorspace id to string" Changes from v4: - removed some redundant functions for traversing media device graph and switched over to using existing ones - avoided accessing struct v4l2_subdev from libmediactl - applied various improvements Changes from v3: - added struct v4l2_subdev and put entity fd and information about supported controls to it - improved functions for negotiating and setting pipeline format by using available libv4lsubdev API - applied minor improvements and cleanups Changes from v2: - switched to using mediatext library for parsing the media device configuration - extended libmediactl - switched to using libmediactl Changes from v1: - removed redundant mbus code negotiation - split the parser, media device helpers and ioctl wrappers to the separate modules - added mechanism for querying extended controls - applied various fixes and modifications The plugin was tested on v4.8-rc2 (exynos4-is driver doesn't proble properly with current master branch of linux-media.git) with patches fixing several issues for Exynos4 camera: [1], [2], [3]. The plugin expects a configuration file: /var/lib/libv4l/exynos4_capture_conf Exemplary configuration file for pipeline with sensor S5C73M3 (rear camera): == link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1] v4l2-ctrl-binding 0x0098091f -> "fimc.0.capture" v4l2-ctrl-binding 0x00980902 -> "S5C73M3" v4l2-ctrl-binding 0x00980922 -> "fimc.0.capture" v4l2-ctrl-binding 0x009a0914 -> "S5C73M3" == With this settings the plugin can be tested on the exynos4412-trats2 board using following gstreamer pipeline: gst-launch-1.0 v4l2src device=/dev/video1 extra-controls="c,rotate=90,color_effects=2" ! video/x-raw,width=960,height=720 ! fbdevsink Exemplary configuration file for pipeline with sensor S5K6A3 (front camera): == link-conf "s5p-mipi-c
Re: [PATCH v4l-utils v7 0/7] Add a plugin for Exynos4 camera
On 11/24/2016 10:10 AM, Mauro Carvalho Chehab wrote: Em Thu, 24 Nov 2016 09:10:28 +0100 Jacek Anaszewski escreveu: On 11/23/2016 10:51 PM, Mauro Carvalho Chehab wrote: Em Thu, 03 Nov 2016 13:13:12 +0100 Jacek Anaszewski escreveu: Hi Hans, On 11/03/2016 12:51 PM, Hans Verkuil wrote: Hi all, Is there anything that blocks me from merging this? This plugin work has been ongoing for years and unless there are serious objections I propose that this is merged. Jacek, is there anything missing that would prevent merging this? There were issues raised by Sakari during last review, related to the way how v4l2 control bindings are defined. That discussion wasn't finished, so I stayed by my approach. Are those things something that could be fixed later without breaking binary apps? If not, then perhaps it is time to merge this. They are related to the format of configuration file being introduced by this patch set, so there are no binary apps depending on it. Ok. Yet, changing the configuration file format could be a pain for the users. The best would be to add a format that would be extensible enough to be able to add support for other needs in the future. Few days ago I had a discussion with Sakari on IRC, and he pointed me to his patch set adding an extended version of his mediatext library RFC [0], the first version of which I included to my patch set, and extended a bit. A decision should be made if I should adapt my API to the mediatext RFC. RFC is not a stable ground though. [0] https://www.spinics.net/lists/linux-media/msg103242.html If I understood well, you're proposing to use this format for the configuration file: link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1] ctrl-to-subdev-conf 0x0098091f -> "fimc.0.capture" ctrl-to-subdev-conf 0x00980902 -> "S5C73M3" ctrl-to-subdev-conf 0x00980922 -> "fimc.0.capture" ctrl-to-subdev-conf 0x009a0914 -> "S5C73M3" What if, instead, you use something like: [group] key = value type of configuration file? This way, if one wants to extend it, all it is needed is to add other groups or more key types. The users with an older configuration won't suffer if newer groups and newer key types were added. E. g something like: [link] source = "s5p-mipi-csis.0":1 sink = "FIMC.0":0 [1] [ctrl-to-subdev] ctrl_id = 0x0098091f subdev= "fimc.0.capture" [ctrl-to-subdev] ctrl_id = 0x00980902 subdev = "S5C73M3" ... This way, Sakari's patches could use the same format to add mediatext entries. E. g. something like (the actual content actually depends on what is here - I'm just wild guessing from the tree diagram at the RFC e-mail): [mediatext] shell_script = foo devnode = /dev/video* devnode = /dev/mediaX devnode = /dev/v4l-subdev* without needing to change the format of the file, and keeping it backward compatible. First version of this patch set used similar configuration format but Sakari asked me to switch to the format accepted by media-ctl, which the first version of mediatext adhered to. Sakari has pledged to review this patch set, so we will be able to decide on how to proceed no sooner than that. Best regards, Jacek Anaszewski Regards, Mauro Other than that - I've tested it and it works fine both with GStreamer and my test app. Best regards, Jacek Anaszewski On 12/10/16 16:35, Jacek Anaszewski wrote: This is a seventh version of the patch series adding a plugin for the Exynos4 camera. Last version [0] of the patch set was posted in January. The plugin doesn't link against libmediactl, but has its sources compiled in. Currently utils are built after the plugins, but libv4l-exynos4-camera plugin depends on the utils. In order to link the plugin against libmediactl the build system would have to be modified. Changes from v6: - close v4l2 sub-devices on media device release - moved non-generic code from libmediactl to the plugin - resigned from adding libmedia_ioctl library and moved all its code to the plugin, since it depended on pipeline representation, which was not generic for all possible media device topologies - used media_get_info()->name instead of adding media_entity_get_name - renamed media_get_backlinks_by_entity() to media_entity_get_backlinks(() - moved pipeline from struct media_device to the plugin - changed the way of associating video device file descriptor with media device - switched to using auto-generated media-bus-format-names.h header file - renamed v4l2-ctrl-redir config entry name to v4l2-ctrl-binding Changes from v5: - fixed and tested use cases with S5K6A3 sensor and FIMC-IS-ISP - added conversion "colorspace id to string" Cha
Re: [PATCH v4l-utils v7 4/7] mediactl: Add media_device creation helpers
Hi Sakari, Thanks for the review. On 11/24/2016 01:17 PM, Sakari Ailus wrote: Hi Jacek, Thanks for the patchset. On Wed, Oct 12, 2016 at 04:35:19PM +0200, Jacek Anaszewski wrote: Add helper functions that allow for easy instantiation of media_device object basing on whether the media device contains v4l2 subdev with given file descriptor. Doesn't this work with video nodes as well? That's what you seem to be using it for later on. And I think that's actually more useful. Exactly, thanks for spotting this. s/v4l2 subdev/video device opened/ The existing implementation uses udev to look up devices. Could you use libudev device enumeration API to find the media devices, and fall back to sysfs if udev doesn't work? There seems to be a reasonable-looking example here: http://stackoverflow.com/questions/25361042/how-to-list-usb-mass-storage-devices-programatically-using-libudev-in-linux> I'll check that, thanks. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 131 +- utils/media-ctl/mediactl.h| 27 + 2 files changed, 156 insertions(+), 2 deletions(-) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 155b65f..d347a40 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -440,8 +441,9 @@ static int media_get_devname_udev(struct udev *udev, return -EINVAL; devnum = makedev(entity->info.v4l.major, entity->info.v4l.minor); - media_dbg(entity->media, "looking up device: %u:%u\n", - major(devnum), minor(devnum)); + if (entity->media) + media_dbg(entity->media, "looking up device: %u:%u\n", + major(devnum), minor(devnum)); device = udev_device_new_from_devnum(udev, 'c', devnum); if (device) { p = udev_device_get_devnode(device); @@ -523,6 +525,7 @@ static int media_get_devname_sysfs(struct media_entity *entity) return 0; } + Unrelated change. static int media_enum_entities(struct media_device *media) { struct media_entity *entity; @@ -707,6 +710,92 @@ struct media_device *media_device_new(const char *devnode) return media; } +struct media_device *media_device_new_by_subdev_fd(int fd, struct media_entity **fd_entity) +{ + char video_devname[32], device_dir_path[256], media_dev_path[256], media_major_minor[10]; + struct media_device *media = NULL; + struct dirent *entry; + struct media_entity tmp_entity; + DIR *device_dir; + struct udev *udev; + char *p; + int ret, i; + + if (fd_entity == NULL) + return NULL; + + ret = media_get_devname_by_fd(fd, video_devname); + if (ret < 0) + return NULL; + + p = strrchr(video_devname, '/'); + if (p == NULL) + return NULL; + + ret = media_udev_open(&udev); + if (ret < 0) + return NULL; + + sprintf(device_dir_path, "/sys/class/video4linux/%s/device/", p + 1); + + device_dir = opendir(device_dir_path); + if (device_dir == NULL) + return NULL; + + while ((entry = readdir(device_dir))) { + if (strncmp(entry->d_name, "media", 4)) Why 4? And isn't entry->d_name nul-terminated, so you could use strcmp()? Media devices, as other devices, have numerical postfix, which is not of our interest. + continue; + + sprintf(media_dev_path, "%s%s/dev", device_dir_path, entry->d_name); + + fd = open(media_dev_path, O_RDONLY); + if (fd < 0) + continue; + + ret = read(fd, media_major_minor, sizeof(media_major_minor)); + if (ret < 0) + continue; + + sscanf(media_major_minor, "%d:%d", &tmp_entity.info.dev.major, &tmp_entity.info.dev.minor); This would be better split on two lines. OK. + + /* Try to get the device name via udev */ + if (media_get_devname_udev(udev, &tmp_entity)) { + /* Fall back to get the device name via sysfs */ + if (media_get_devname_sysfs(&tmp_entity)) + continue; + } + + media = media_device_new(tmp_entity.devname); + if (media == NULL) + continue; + + ret = media_device_enumerate(media); + if (ret < 0) { + media_dbg(media, "Failed to enumerate %s (%d)\n", + tmp_entity.devname, ret); +
Re: [PATCH v4l-utils v7 3/7] mediactl: Add media_entity_get_backlinks()
Hi Sakari, Thanks for the review. On 11/24/2016 01:40 PM, Sakari Ailus wrote: Hi Jacek, On Wed, Oct 12, 2016 at 04:35:18PM +0200, Jacek Anaszewski wrote: Add a new graph helper useful for discovering video pipeline. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 21 + utils/media-ctl/mediactl.h| 15 +++ 2 files changed, 36 insertions(+) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 91ed003..155b65f 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -36,6 +36,7 @@ #include #include +#include Is there something that needs this one in the patch? MAJOR and MINOR macros. #include #include "mediactl.h" @@ -172,6 +173,26 @@ const struct media_entity_desc *media_entity_get_info(struct media_entity *entit return &entity->info; } +int media_entity_get_backlinks(struct media_entity *entity, + struct media_link **backlinks, + unsigned int *num_backlinks) +{ + unsigned int num_bklinks = 0; + int i; + + if (entity == NULL || backlinks == NULL || num_backlinks == NULL) + return -EINVAL; + If you have an interface that accesses a memory buffer of unknown size, you need to verify that the user has provided a buffer large enough. How about using the num_backlinks argument to provide the maximum size to the function, and passing the actual number to the user, the latter of which you already do? Sounds reasonable. Alternatively, an iterator style API could be nice as well. Up to you. It would probably need an addition of some generic infrastructure. I suppose that there is no such a feature in v4l-utils? I wonder what Laurent thinks. + for (i = 0; i < entity->num_links; ++i) + if ((entity->links[i].flags & MEDIA_LNK_FL_ENABLED) && + (entity->links[i].sink->entity == entity)) + backlinks[num_bklinks++] = &entity->links[i]; + + *num_backlinks = num_bklinks; + + return 0; +} + /* - * Open/close */ diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h index 336cbf9..b1f33cd 100644 --- a/utils/media-ctl/mediactl.h +++ b/utils/media-ctl/mediactl.h @@ -434,6 +434,20 @@ int media_parse_setup_link(struct media_device *media, int media_parse_setup_links(struct media_device *media, const char *p); /** + * @brief Get entity's enabled backlinks + * @param entity - media entity. + * @param backlinks - array of pointers to matching backlinks. + * @param num_backlinks - number of matching backlinks. + * + * Get links that are connected to the entity sink pads. + * + * @return 0 on success, or a negative error code on failure. + */ +int media_entity_get_backlinks(struct media_entity *entity, + struct media_link **backlinks, + unsigned int *num_backlinks); + +/** * @brief Get v4l2_subdev for the entity * @param entity - media entity * @@ -443,4 +457,5 @@ int media_parse_setup_links(struct media_device *media, const char *p); */ struct v4l2_subdev *media_entity_get_v4l2_subdev(struct media_entity *entity); + Unrelated change. #endif -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4l-utils v7 2/7] mediatext: Add library
Hi Sakari, On 11/24/2016 02:01 PM, Sakari Ailus wrote: Hi Jacek, On Wed, Oct 12, 2016 at 04:35:17PM +0200, Jacek Anaszewski wrote: libmediatext is a helper library for converting configurations (Media controller links, V4L2 controls and V4L2 sub-device media bus formats and selections) from text-based form into IOCTLs. libmediatext depends on libv4l2subdev and libmediactl. I'm not very happy with the plugin using the mediatext library as it was in 2013. I've heavily changed (and extended) the library since to cover additional use cases such as the request API: http://www.spinics.net/lists/linux-media/msg103242.html> This version is not meaningfully extensible in forward-compatible way. In order to resolve the matter quickly without making merging the further developed library difficult, I propose merging the code to the plugin itself. We could later check if it could be refactored. How about that? It works for me. Thanks, Jacek Anaszewski Signed-off-by: Sakari Ailus Signed-off-by: Teemu Tuominen Signed-off-by: Jacek Anaszewski --- utils/media-ctl/Makefile.am| 10 +- utils/media-ctl/libmediatext.pc.in | 10 ++ utils/media-ctl/mediatext-test.c | 64 utils/media-ctl/mediatext.c| 312 + utils/media-ctl/mediatext.h| 52 +++ 5 files changed, 446 insertions(+), 2 deletions(-) create mode 100644 utils/media-ctl/libmediatext.pc.in create mode 100644 utils/media-ctl/mediatext-test.c create mode 100644 utils/media-ctl/mediatext.c create mode 100644 utils/media-ctl/mediatext.h diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am index ee7dcc9..2f12357 100644 --- a/utils/media-ctl/Makefile.am +++ b/utils/media-ctl/Makefile.am @@ -1,4 +1,4 @@ -noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la +noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS) @@ -21,9 +21,15 @@ libv4l2subdev_la_LIBADD = libmediactl.la libv4l2subdev_la_CFLAGS = -static libv4l2subdev_la_LDFLAGS = -static +libmediatext_la_SOURCES = mediatext.c +libmediatext_la_CFLAGS = -static $(LIBUDEV_CFLAGS) +libmediatext_la_LDFLAGS = -static $(LIBUDEV_LIBS) + mediactl_includedir=$(includedir)/mediactl noinst_HEADERS = mediactl.h v4l2subdev.h -bin_PROGRAMS = media-ctl +bin_PROGRAMS = media-ctl mediatext-test media_ctl_SOURCES = media-ctl.c options.c options.h tools.h media_ctl_LDADD = libmediactl.la libv4l2subdev.la +mediatext_test_SOURCES = mediatext-test.c +mediatext_test_LDADD = libmediatext.la libmediactl.la libv4l2subdev.la diff --git a/utils/media-ctl/libmediatext.pc.in b/utils/media-ctl/libmediatext.pc.in new file mode 100644 index 000..6aa6353 --- /dev/null +++ b/utils/media-ctl/libmediatext.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmediatext +Description: Media controller and V4L2 text-based configuration library +Version: @PACKAGE_VERSION@ +Cflags: -I${includedir} +Libs: -L${libdir} -lmediatext diff --git a/utils/media-ctl/mediatext-test.c b/utils/media-ctl/mediatext-test.c new file mode 100644 index 000..b8b9282 --- /dev/null +++ b/utils/media-ctl/mediatext-test.c @@ -0,0 +1,64 @@ +/* + * libmediatext test program + * + * Copyright (C) 2013 Intel Corporation + * + * Contact: Sakari Ailus + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include + +#include "mediactl.h" +#include "mediatext.h" + +int main(int argc, char *argv[]) +{ + struct media_device *device; + int rval; + + if (argc != 3) { + fprintf(stderr, "usage: %s \n\n", argv[0]); + fprintf(stderr, "\tstring := [ v4l2-ctrl |?v4l2-mbus | link-reset | link-conf]\n\n"); + fprintf(stderr, "\tv4l2-ctrl := \"entity\" ctrl_type ctrl_id ctrl_value\n"); + fprintf(stderr, "\tctrl_type := [ int | int64 | bitmask ]\n"); + fprintf(stderr, "\tctrl_value := [ %%d | %%PRId64 | bitmask_value ]\n"); + fprintf(stderr, "\tbitmask_value := b\n\n"); + fprintf(stderr, "\t
Re: [PATCH v4l-utils v7 4/7] mediactl: Add media_device creation helpers
On 11/24/2016 03:32 PM, Sakari Ailus wrote: [...] + sprintf(device_dir_path, "/sys/class/video4linux/%s/device/", p + 1); + + device_dir = opendir(device_dir_path); + if (device_dir == NULL) + return NULL; + + while ((entry = readdir(device_dir))) { + if (strncmp(entry->d_name, "media", 4)) Why 4? And isn't entry->d_name nul-terminated, so you could use strcmp()? Media devices, as other devices, have numerical postfix, which is not of our interest. Right. But still 5 would be the right number as we should also check the last "a". Of course, this needs to be fixed, thanks. -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4l-utils v7 6/7] mediactl: libv4l2subdev: add support for comparing mbus formats
On 11/24/2016 03:36 PM, Sakari Ailus wrote: Hi Jacek, On Wed, Oct 12, 2016 at 04:35:21PM +0200, Jacek Anaszewski wrote: This patch adds a function for checking whether two mbus formats are compatible. Compatible doesn't in general case mean the same as... the same. On parallel busses a 10-bit source can be connected to an 8-bit sink-for instance. How about moving this to the plugin, and if someone else needs it, then we move it out later? This is a good idea, as I am checking not all fields of v4l2_mbus_framefmt, but only those which matter during Exynos4 media devuce pipeline format negotiation. -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4l-utils v7 7/7] Add a libv4l plugin for Exynos4 camera
Hi Sakari, On 11/24/2016 04:11 PM, Sakari Ailus wrote: Hi Jacek, Thank you for your continued work on the Exynos plugin patchset! I think we're pretty close to being able to merge the set, if you could still bear with me awhile. :-) Your demanding reviewer I must admit. :-) Of course, I appreciate all your remarks, they're highly valuable. On Wed, Oct 12, 2016 at 04:35:22PM +0200, Jacek Anaszewski wrote: ... diff --git a/lib/libv4l-exynos4-camera/Makefile.am b/lib/libv4l-exynos4-camera/Makefile.am new file mode 100644 index 000..c38b7f6 --- /dev/null +++ b/lib/libv4l-exynos4-camera/Makefile.am @@ -0,0 +1,19 @@ +if WITH_V4L_PLUGINS +libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la +endif + +media-bus-format-names.h: ../../include/linux/media-bus-format.h + sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \ + < $< > $@ + +media-bus-format-codes.h: ../../include/linux/media-bus-format.h + sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \ + < $< > $@ + +BUILT_SOURCES = media-bus-format-names.h media-bus-format-codes.h +CLEANFILES = $(BUILT_SOURCES) It'd be nice to be able to use the same generated headers that now are under utils/media-ctl, instead of copying the sed script here in verbatim. If the script is changed or fixed in some way, the other location probably will remain unchanged... The problem is that those headers are built after this plugin. I wonder if there's a proper way to generate build time headers such as these. Another less good alternative would be to put these into a separate Makefile and include that Makefile where the headers are needed. But I don't like that much either, it's a hack. In this case it seems to be the only feasible optimization. + +nodist_libv4l_exynos4_camera_la_SOURCES = $(BUILT_SOURCES) +libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c ../../utils/media-ctl/libmediactl.c ../../utils/media-ctl/libv4l2subdev.c ../../utils/media-ctl/mediatext.c +libv4l_exynos4_camera_la_CFLAGS = -fvisibility=hidden -std=gnu99 +libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -lpthread diff --git a/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c new file mode 100644 index 000..c219fe5 --- /dev/null +++ b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c @@ -0,0 +1,1325 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Author: Jacek Anaszewski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../utils/media-ctl/mediactl.h" +#include "../../utils/media-ctl/mediatext.h" +#include "../../utils/media-ctl/v4l2subdev.h" +#include "libv4l-plugin.h" + +#ifdef DEBUG +#define V4L2_EXYNOS4_DBG(format, ARG...)\ + printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, ##ARG) +#else +#define V4L2_EXYNOS4_DBG(format, ARG...) +#endif + +#define V4L2_EXYNOS4_ERR(format, ARG...)\ + fprintf(stderr, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG) + +#define V4L2_EXYNOS4_LOG(format, ARG...)\ + fprintf(stdout, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG) + +#define VIDIOC_CTRL(type) \ + ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" : \ + "VIDIOC_G_CTRL") + +#if HAVE_VISIBILITY +#define PLUGIN_PUBLIC __attribute__ ((visibility("default"))) +#else +#define PLUGIN_PUBLIC +#endif + +#define SYS_IOCTL(fd, cmd, arg) \ + syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg)) + +#define SIMPLE_CONVERT_IOCTL(fd, cmd, arg, __struc) ({ \ + int __ret; \ + struct __struc *req = arg; \ + uint32_t type = req->type; \ + req->type = convert_type(type); \ + __ret = SYS_IOCTL(fd, cmd, arg);\ + req->type = type; \ + __ret; \ + }) + +#
Re: [PATCH v4l-utils v7 1/7] mediactl: Add support for v4l2-ctrl-binding config
Hi Sakari, On 11/24/2016 03:23 PM, Sakari Ailus wrote: Hi Jacek, On Wed, Oct 12, 2016 at 04:35:16PM +0200, Jacek Anaszewski wrote: Make struct v4l2_subdev capable of aggregating v4l2-ctrl-bindings - media device configuration entries. Added are also functions for validating support for the control on given media entity and checking whether a v4l2-ctrl-binding has been defined for a media entity. I still don't think this belongs here. I think I told you about the generic pipeline configuration library I worked on years ago; unfortunately it was left on prototype stage. Still, what I realised was that something very similar is needed in that library --- associating information to the representation of the media entities (or the V4L2 sub-devices) in user space that has got nothing to do with the devices themselves. We could have e.g. a list of key--value pairs where the key is a pointer provided by the user (i.e. application, another library) that could be associated with the value. That would avoid having explicit information on that in the struct media_entity itself. An quicker alternative would be to manage a list of controls e.g. in the plugin itself and store the media entity where they're implemented in that list, with the control value. We are not interested in media entity -> control value relation but but media entity -> control id. The value is an arbitrary choice of userspace. Binding's task is to route the ctrl ioctl to a desired pipeline entity if more than one supports same control. Effectively we'd need a list of controls as a keys and entities as values. The list should be allocated dynamically as it would make no sense to keep keys for all v4l2 controls if only few bindings are defined. Best regards, Jacek Anaszewski Cc Laurent as well. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libv4l2subdev.c | 32 utils/media-ctl/v4l2subdev.h| 19 +++ 2 files changed, 51 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index c3439d7..4f8ee7f 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -50,7 +50,15 @@ int v4l2_subdev_create(struct media_entity *entity) entity->sd->fd = -1; + entity->sd->v4l2_ctrl_bindings = malloc(sizeof(__u32)); + if (entity->sd->v4l2_ctrl_bindings == NULL) + goto err_v4l2_ctrl_bindings_alloc; + return 0; + +err_v4l2_ctrl_bindings_alloc: + free(entity->sd); + return -ENOMEM; } int v4l2_subdev_create_opened(struct media_entity *entity, int fd) @@ -102,6 +110,7 @@ void v4l2_subdev_close(struct media_entity *entity) if (entity->sd->fd_owner) close(entity->sd->fd); + free(entity->sd->v4l2_ctrl_bindings); free(entity->sd); } @@ -884,3 +893,26 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(unsigned int *length) return mbus_codes; } + +int v4l2_subdev_supports_v4l2_ctrl(struct media_device *media, + struct media_entity *entity, + __u32 ctrl_id) +{ + struct v4l2_queryctrl queryctrl = {}; + int ret; + + ret = v4l2_subdev_open(entity); + if (ret < 0) + return ret; + + queryctrl.id = ctrl_id; + + ret = ioctl(entity->sd->fd, VIDIOC_QUERYCTRL, &queryctrl); + if (ret < 0) + return ret; + + media_dbg(media, "Validated control \"%s\" (0x%8.8x) on entity %s\n", + queryctrl.name, queryctrl.id, entity->info.name); + + return 0; +} diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 011fab1..4dee6b1 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -26,10 +26,14 @@ struct media_device; struct media_entity; +struct media_device; struct v4l2_subdev { int fd; unsigned int fd_owner:1; + + __u32 *v4l2_ctrl_bindings; + unsigned int num_v4l2_ctrl_bindings; }; /** @@ -314,4 +318,19 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string); const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( unsigned int *length); +/** + * @brief Check if sub-device supports given v4l2 control + * @param media - media device. + * @param entity - media entity. + * @param ctrl_id - id of the v4l2 control to check. + * + * Verify if the sub-device associated with given media entity + * supports v4l2-control with given ctrl_id. + * + * @return 1 if the control is supported, 0 otherwise. + */ +int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, + struct media_entity *entity, + __u32 ctrl_id); + #endif -- To unsubscribe from this list: send the line &
Re: [PATCH v4l-utils v7 4/7] mediactl: Add media_device creation helpers
Hi Sakari, On 11/24/2016 01:17 PM, Sakari Ailus wrote: Hi Jacek, Thanks for the patchset. On Wed, Oct 12, 2016 at 04:35:19PM +0200, Jacek Anaszewski wrote: Add helper functions that allow for easy instantiation of media_device object basing on whether the media device contains v4l2 subdev with given file descriptor. Doesn't this work with video nodes as well? That's what you seem to be using it for later on. And I think that's actually more useful. The existing implementation uses udev to look up devices. Could you use libudev device enumeration API to find the media devices, and fall back to sysfs if udev doesn't work? There seems to be a reasonable-looking example here: http://stackoverflow.com/questions/25361042/how-to-list-usb-mass-storage-devices-programatically-using-libudev-in-linux> Actually I am calling media_get_devname_udev() at first and falling back to sysfs similarly as it is accomplished in media_enum_entities(). Is there any specific reason for which I should use libudev device enumeration API in media_device_new_by_subdev_fd()? Best regards, Jacek Anaszewski Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 131 +- utils/media-ctl/mediactl.h| 27 + 2 files changed, 156 insertions(+), 2 deletions(-) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 155b65f..d347a40 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -440,8 +441,9 @@ static int media_get_devname_udev(struct udev *udev, return -EINVAL; devnum = makedev(entity->info.v4l.major, entity->info.v4l.minor); - media_dbg(entity->media, "looking up device: %u:%u\n", - major(devnum), minor(devnum)); + if (entity->media) + media_dbg(entity->media, "looking up device: %u:%u\n", + major(devnum), minor(devnum)); device = udev_device_new_from_devnum(udev, 'c', devnum); if (device) { p = udev_device_get_devnode(device); @@ -523,6 +525,7 @@ static int media_get_devname_sysfs(struct media_entity *entity) return 0; } + Unrelated change. static int media_enum_entities(struct media_device *media) { struct media_entity *entity; @@ -707,6 +710,92 @@ struct media_device *media_device_new(const char *devnode) return media; } +struct media_device *media_device_new_by_subdev_fd(int fd, struct media_entity **fd_entity) +{ + char video_devname[32], device_dir_path[256], media_dev_path[256], media_major_minor[10]; + struct media_device *media = NULL; + struct dirent *entry; + struct media_entity tmp_entity; + DIR *device_dir; + struct udev *udev; + char *p; + int ret, i; + + if (fd_entity == NULL) + return NULL; + + ret = media_get_devname_by_fd(fd, video_devname); + if (ret < 0) + return NULL; + + p = strrchr(video_devname, '/'); + if (p == NULL) + return NULL; + + ret = media_udev_open(&udev); + if (ret < 0) + return NULL; + + sprintf(device_dir_path, "/sys/class/video4linux/%s/device/", p + 1); + + device_dir = opendir(device_dir_path); + if (device_dir == NULL) + return NULL; + + while ((entry = readdir(device_dir))) { + if (strncmp(entry->d_name, "media", 4)) Why 4? And isn't entry->d_name nul-terminated, so you could use strcmp()? + continue; + + sprintf(media_dev_path, "%s%s/dev", device_dir_path, entry->d_name); + + fd = open(media_dev_path, O_RDONLY); + if (fd < 0) + continue; + + ret = read(fd, media_major_minor, sizeof(media_major_minor)); + if (ret < 0) + continue; + + sscanf(media_major_minor, "%d:%d", &tmp_entity.info.dev.major, &tmp_entity.info.dev.minor); This would be better split on two lines. + + /* Try to get the device name via udev */ + if (media_get_devname_udev(udev, &tmp_entity)) { + /* Fall back to get the device name via sysfs */ + if (media_get_devname_sysfs(&tmp_entity)) + continue; + } + + media = media_device_new(tmp_entity.devname); + if (media == NULL) + continue; + + ret = media_device_enumerate(media); + if (ret < 0) { + media_dbg(media, "Failed
Re: [PATCH v4l-utils v7 4/7] mediactl: Add media_device creation helpers
Hhi Sakari, On 12/09/2016 12:05 AM, Sakari Ailus wrote: Hi Jacek, On Thu, Dec 08, 2016 at 11:04:20PM +0100, Jacek Anaszewski wrote: Hi Sakari, On 11/24/2016 01:17 PM, Sakari Ailus wrote: Hi Jacek, Thanks for the patchset. On Wed, Oct 12, 2016 at 04:35:19PM +0200, Jacek Anaszewski wrote: Add helper functions that allow for easy instantiation of media_device object basing on whether the media device contains v4l2 subdev with given file descriptor. Doesn't this work with video nodes as well? That's what you seem to be using it for later on. And I think that's actually more useful. The existing implementation uses udev to look up devices. Could you use libudev device enumeration API to find the media devices, and fall back to sysfs if udev doesn't work? There seems to be a reasonable-looking example here: http://stackoverflow.com/questions/25361042/how-to-list-usb-mass-storage-devices-programatically-using-libudev-in-linux> Actually I am calling media_get_devname_udev() at first and falling back to sysfs similarly as it is accomplished in media_enum_entities(). Is there any specific reason for which I should use libudev device enumeration API in media_device_new_by_subdev_fd()? Yes. You rely on the API udev provides; the sysfs implementation is just a fallback in case udev isn't available in the system. I guess it'd mostly work but, for instance, you assume sysfs is found under /sys. The sysfs itself isn't one of the most stable APIs either. Udev is a simply better option when it's there. Thanks for clarifying that. I'll check the libudev device enumeration API then. -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] media: s5p-jpeg add missing blank lines after declarations
Hi Shuah, Thanks for the patch. On 07/14/2016 10:01 PM, Shuah Khan wrote: Missing blank lines after declarations are making it hard to read the code. Fix them and also fix other checkpatch warnings at the same time. Signed-off-by: Shuah Khan --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 17bc94092..fe5554f 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -537,6 +537,7 @@ static const u32 fourcc_to_dwngrd_schema_id[] = { static int s5p_jpeg_get_dwngrd_sch_id_by_fourcc(u32 fourcc) { int i; + for (i = 0; i < ARRAY_SIZE(fourcc_to_dwngrd_schema_id); ++i) { if (fourcc_to_dwngrd_schema_id[i] == fourcc) return i; @@ -1273,7 +1274,8 @@ static int enum_fmt(struct s5p_jpeg_fmt *sjpeg_formats, int n, if (num == f->index) break; /* Correct type but haven't reached our index yet, -* just increment per-type index */ +* just increment per-type index + */ ++num; } } @@ -1349,6 +1351,7 @@ static int s5p_jpeg_g_fmt(struct file *file, void *priv, struct v4l2_format *f) pix->bytesperline = 0; if (q_data->fmt->fourcc != V4L2_PIX_FMT_JPEG) { u32 bpl = q_data->w; + if (q_data->fmt->colplanes == 1) bpl = (bpl * q_data->fmt->depth) >> 3; pix->bytesperline = bpl; @@ -1374,6 +1377,7 @@ static struct s5p_jpeg_fmt *s5p_jpeg_find_format(struct s5p_jpeg_ctx *ctx, for (k = 0; k < ARRAY_SIZE(sjpeg_formats); k++) { struct s5p_jpeg_fmt *fmt = &sjpeg_formats[k]; + if (fmt->fourcc == pixelformat && fmt->flags & fmt_flag && fmt->flags & ctx->jpeg->variant->fmt_ver_flag) { @@ -1431,7 +1435,8 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt, return -EINVAL; /* V4L2 specification suggests the driver corrects the format struct -* if any of the dimensions is unsupported */ +* if any of the dimensions is unsupported + */ if (q_type == FMT_TYPE_OUTPUT) jpeg_bound_align_image(ctx, &pix->width, S5P_JPEG_MIN_WIDTH, S5P_JPEG_MAX_WIDTH, 0, @@ -2490,6 +2495,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) if (ctx->mode == S5P_JPEG_DECODE && vb->vb2_queue->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { struct s5p_jpeg_q_data tmp, *q_data; + ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp, (unsigned long)vb2_plane_vaddr(vb, 0), min((unsigned long)ctx->out_q.size, @@ -3025,7 +3031,8 @@ static int s5p_jpeg_resume(struct device *dev) static const struct dev_pm_ops s5p_jpeg_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(s5p_jpeg_suspend, s5p_jpeg_resume) - SET_RUNTIME_PM_OPS(s5p_jpeg_runtime_suspend, s5p_jpeg_runtime_resume, NULL) + SET_RUNTIME_PM_OPS(s5p_jpeg_runtime_suspend, s5p_jpeg_runtime_resume, + NULL) }; static struct s5p_jpeg_variant s5p_jpeg_drvdata = { Acked-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] [media] platform: constify vb2_ops structures
Hi Julia, On 09/09/2016 01:59 AM, Julia Lawall wrote: 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/) [...] diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 785e693..d9c07b8 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -2538,7 +2538,7 @@ static void s5p_jpeg_stop_streaming(struct vb2_queue *q) pm_runtime_put(ctx->jpeg->dev); } -static struct vb2_ops s5p_jpeg_qops = { +static const struct vb2_ops s5p_jpeg_qops = { .queue_setup= s5p_jpeg_queue_setup, .buf_prepare= s5p_jpeg_buf_prepare, .buf_queue = s5p_jpeg_buf_queue, diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index e967fcf..44323cb 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -1379,7 +1379,7 @@ static void cal_stop_streaming(struct vb2_queue *vq) cal_runtime_put(ctx->dev); } Thanks for the patch. For s5p-jpeg driver: Reviewed-by: Jacek Anaszewski -- Best regards, Jacek Anaszewski -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4l-utils v7 6/7] mediactl: libv4l2subdev: add support for comparing mbus formats
This patch adds a function for checking whether two mbus formats are compatible. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libv4l2subdev.c | 42 + utils/media-ctl/v4l2subdev.h| 21 + 2 files changed, 63 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 31393bb..2ec9b5e 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -948,3 +948,45 @@ int v4l2_subdev_supports_v4l2_ctrl(struct media_device *media, return 0; } + +enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare( + struct v4l2_mbus_framefmt *fmt1, + struct v4l2_mbus_framefmt *fmt2) +{ + if (fmt1 == NULL || fmt2 == NULL) + return 0; + + if (fmt1->width != fmt2->width) { + printf("width mismatch (fmt1: %d, fmt2: %d)\n", + fmt1->width, fmt2->width); + return FMT_MISMATCH_WIDTH; + } + + if (fmt1->height != fmt2->height) { + printf("height mismatch (fmt1: %d, fmt2: %d)\n", + fmt1->height, fmt2->height); + return FMT_MISMATCH_HEIGHT; + } + + if (fmt1->code != fmt2->code) { + printf("mbus code mismatch (fmt1: %s, fmt2: %s)\n", + v4l2_subdev_pixelcode_to_string(fmt1->code), + v4l2_subdev_pixelcode_to_string(fmt2->code)); + return FMT_MISMATCH_CODE; + } + + if (fmt1->field != fmt2->field) { + printf("field mismatch (fmt1: %d, fmt2: %d)\n", + fmt1->field, fmt2->field); + return FMT_MISMATCH_FIELD; + } + + if (fmt1->colorspace != fmt2->colorspace) { + printf("colorspace mismatch (fmt1: %s, fmt2: %s)\n", + v4l2_subdev_colorspace_to_string(fmt1->colorspace), + v4l2_subdev_colorspace_to_string(fmt2->colorspace)); + return FMT_MISMATCH_COLORSPACE; + } + + return FMT_MISMATCH_NONE; +} diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index cf1250d..c438f71 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -28,6 +28,15 @@ struct media_device; struct media_entity; struct media_device; +enum v4l2_subdev_fmt_mismatch { + FMT_MISMATCH_NONE = 0, + FMT_MISMATCH_WIDTH, + FMT_MISMATCH_HEIGHT, + FMT_MISMATCH_CODE, + FMT_MISMATCH_FIELD, + FMT_MISMATCH_COLORSPACE, +}; + struct v4l2_subdev { int fd; unsigned int fd_owner:1; @@ -342,5 +351,17 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, struct media_entity *entity, __u32 ctrl_id); +/** + * @brief Compare mbus formats + * @param fmt1 - 1st mbus format to compare. + * @param fmt2 - 2nd mbus format to compare. + * + * Check whether two mbus formats are compatible. + * + * @return 1 if formats are compatible, 0 otherwise. + */ +enum v4l2_subdev_fmt_mismatch v4l2_subdev_format_compare( + struct v4l2_mbus_framefmt *fmt1, + struct v4l2_mbus_framefmt *fmt2); #endif -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4l-utils v7 7/7] Add a libv4l plugin for Exynos4 camera
The plugin provides support for the media device on Exynos4 SoC. It performs single plane <-> multi plane API conversion, video pipeline linking and takes care of automatic data format negotiation for the whole pipeline, after intercepting VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- configure.ac |1 + lib/Makefile.am |5 + lib/libv4l-exynos4-camera/Makefile.am | 19 + lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 1325 + 4 files changed, 1350 insertions(+) create mode 100644 lib/libv4l-exynos4-camera/Makefile.am create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c diff --git a/configure.ac b/configure.ac index 8447f05..692718a 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AC_CONFIG_FILES([Makefile lib/libdvbv5/Makefile lib/libv4l2rds/Makefile lib/libv4l-mplane/Makefile + lib/libv4l-exynos4-camera/Makefile utils/Makefile utils/libv4l2util/Makefile diff --git a/lib/Makefile.am b/lib/Makefile.am index a105c95..b5e52db 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,6 +5,11 @@ SUBDIRS = \ libv4l2rds \ libv4l-mplane +if WITH_V4LUTILS +SUBDIRS += \ + libv4l-exynos4-camera +endif + if WITH_LIBDVBV5 SUBDIRS += \ libdvbv5 diff --git a/lib/libv4l-exynos4-camera/Makefile.am b/lib/libv4l-exynos4-camera/Makefile.am new file mode 100644 index 000..c38b7f6 --- /dev/null +++ b/lib/libv4l-exynos4-camera/Makefile.am @@ -0,0 +1,19 @@ +if WITH_V4L_PLUGINS +libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la +endif + +media-bus-format-names.h: ../../include/linux/media-bus-format.h + sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \ + < $< > $@ + +media-bus-format-codes.h: ../../include/linux/media-bus-format.h + sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \ + < $< > $@ + +BUILT_SOURCES = media-bus-format-names.h media-bus-format-codes.h +CLEANFILES = $(BUILT_SOURCES) + +nodist_libv4l_exynos4_camera_la_SOURCES = $(BUILT_SOURCES) +libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c ../../utils/media-ctl/libmediactl.c ../../utils/media-ctl/libv4l2subdev.c ../../utils/media-ctl/mediatext.c +libv4l_exynos4_camera_la_CFLAGS = -fvisibility=hidden -std=gnu99 +libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -lpthread diff --git a/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c new file mode 100644 index 000..c219fe5 --- /dev/null +++ b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c @@ -0,0 +1,1325 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Author: Jacek Anaszewski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../utils/media-ctl/mediactl.h" +#include "../../utils/media-ctl/mediatext.h" +#include "../../utils/media-ctl/v4l2subdev.h" +#include "libv4l-plugin.h" + +#ifdef DEBUG +#define V4L2_EXYNOS4_DBG(format, ARG...)\ + printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, ##ARG) +#else +#define V4L2_EXYNOS4_DBG(format, ARG...) +#endif + +#define V4L2_EXYNOS4_ERR(format, ARG...)\ + fprintf(stderr, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG) + +#define V4L2_EXYNOS4_LOG(format, ARG...)\ + fprintf(stdout, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG) + +#define VIDIOC_CTRL(type) \ + ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" :\ + "VIDIOC_G_CTRL") + +#if HAVE_VISIBILITY +#define PLUGIN_PUBLIC __attribute__ ((visibility("default"))) +#else +#define PLUGIN_PUBLIC +#endif + +#define SYS_IOCTL(fd, cmd, arg) \ + syscall(SYS_ioctl, (int)(fd), (unsigned long)(cmd), (void *)(arg)) + +#define SIMPLE_CONVERT_IOCTL(fd, cmd, arg, __struc) ({ \ + int __ret; \ + struct _
[PATCH v4l-utils v7 2/7] mediatext: Add library
libmediatext is a helper library for converting configurations (Media controller links, V4L2 controls and V4L2 sub-device media bus formats and selections) from text-based form into IOCTLs. libmediatext depends on libv4l2subdev and libmediactl. Signed-off-by: Sakari Ailus Signed-off-by: Teemu Tuominen Signed-off-by: Jacek Anaszewski --- utils/media-ctl/Makefile.am| 10 +- utils/media-ctl/libmediatext.pc.in | 10 ++ utils/media-ctl/mediatext-test.c | 64 utils/media-ctl/mediatext.c| 312 + utils/media-ctl/mediatext.h| 52 +++ 5 files changed, 446 insertions(+), 2 deletions(-) create mode 100644 utils/media-ctl/libmediatext.pc.in create mode 100644 utils/media-ctl/mediatext-test.c create mode 100644 utils/media-ctl/mediatext.c create mode 100644 utils/media-ctl/mediatext.h diff --git a/utils/media-ctl/Makefile.am b/utils/media-ctl/Makefile.am index ee7dcc9..2f12357 100644 --- a/utils/media-ctl/Makefile.am +++ b/utils/media-ctl/Makefile.am @@ -1,4 +1,4 @@ -noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la +noinst_LTLIBRARIES = libmediactl.la libv4l2subdev.la libmediatext.la libmediactl_la_SOURCES = libmediactl.c mediactl-priv.h libmediactl_la_CFLAGS = -static $(LIBUDEV_CFLAGS) @@ -21,9 +21,15 @@ libv4l2subdev_la_LIBADD = libmediactl.la libv4l2subdev_la_CFLAGS = -static libv4l2subdev_la_LDFLAGS = -static +libmediatext_la_SOURCES = mediatext.c +libmediatext_la_CFLAGS = -static $(LIBUDEV_CFLAGS) +libmediatext_la_LDFLAGS = -static $(LIBUDEV_LIBS) + mediactl_includedir=$(includedir)/mediactl noinst_HEADERS = mediactl.h v4l2subdev.h -bin_PROGRAMS = media-ctl +bin_PROGRAMS = media-ctl mediatext-test media_ctl_SOURCES = media-ctl.c options.c options.h tools.h media_ctl_LDADD = libmediactl.la libv4l2subdev.la +mediatext_test_SOURCES = mediatext-test.c +mediatext_test_LDADD = libmediatext.la libmediactl.la libv4l2subdev.la diff --git a/utils/media-ctl/libmediatext.pc.in b/utils/media-ctl/libmediatext.pc.in new file mode 100644 index 000..6aa6353 --- /dev/null +++ b/utils/media-ctl/libmediatext.pc.in @@ -0,0 +1,10 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: libmediatext +Description: Media controller and V4L2 text-based configuration library +Version: @PACKAGE_VERSION@ +Cflags: -I${includedir} +Libs: -L${libdir} -lmediatext diff --git a/utils/media-ctl/mediatext-test.c b/utils/media-ctl/mediatext-test.c new file mode 100644 index 000..b8b9282 --- /dev/null +++ b/utils/media-ctl/mediatext-test.c @@ -0,0 +1,64 @@ +/* + * libmediatext test program + * + * Copyright (C) 2013 Intel Corporation + * + * Contact: Sakari Ailus + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include +#include +#include + +#include "mediactl.h" +#include "mediatext.h" + +int main(int argc, char *argv[]) +{ + struct media_device *device; + int rval; + + if (argc != 3) { + fprintf(stderr, "usage: %s \n\n", argv[0]); + fprintf(stderr, "\tstring := [ v4l2-ctrl |�v4l2-mbus | link-reset | link-conf]\n\n"); + fprintf(stderr, "\tv4l2-ctrl := \"entity\" ctrl_type ctrl_id ctrl_value\n"); + fprintf(stderr, "\tctrl_type := [ int | int64 | bitmask ]\n"); + fprintf(stderr, "\tctrl_value := [ %%d | %%PRId64 | bitmask_value ]\n"); + fprintf(stderr, "\tbitmask_value := b\n\n"); + fprintf(stderr, "\tv4l2-mbus := \n"); + fprintf(stderr, "\tlink-conf := \"entity\":pad -> \"entity\":pad[link-flags]\n"); + fprintf(stderr, "\tv4l2-ctrl-binding := ctrl_id -> \"entity\"\n"); + return EXIT_FAILURE; + } + + device = media_device_new(argv[1]); + if (!device) + return EXIT_FAILURE; + + rval = media_device_enumerate(device); + if (rval) + return EXIT_FAILURE; + + rval = mediatext_parse(device, argv[2]); + if (rval) { + fprintf(stderr, "bad string %s (%s)\n", argv[2], strerror(-rval)); + return EXIT_FAILURE; + } + + media_device_unref
[PATCH v4l-utils v7 5/7] mediactl: libv4l2subdev: Add colorspace logging
Add a function for obtaining colorspace name by id. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libv4l2subdev.c | 32 utils/media-ctl/v4l2subdev.h| 10 ++ 2 files changed, 42 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index 4f8ee7f..31393bb 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -33,6 +33,7 @@ #include #include +#include #include "mediactl.h" #include "mediactl-priv.h" @@ -831,6 +832,37 @@ const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code) return "unknown"; } +static struct { + const char *name; + enum v4l2_colorspace cs; +} colorspaces[] = { +{ "DEFAULT", V4L2_COLORSPACE_DEFAULT }, +{ "SMPTE170M", V4L2_COLORSPACE_SMPTE170M }, +{ "SMPTE240M", V4L2_COLORSPACE_SMPTE240M }, +{ "REC709", V4L2_COLORSPACE_REC709 }, +{ "BT878", V4L2_COLORSPACE_BT878 }, +{ "470_SYSTEM_M", V4L2_COLORSPACE_470_SYSTEM_M }, +{ "470_SYSTEM_BG", V4L2_COLORSPACE_470_SYSTEM_BG }, +{ "JPEG", V4L2_COLORSPACE_JPEG }, +{ "SRGB", V4L2_COLORSPACE_SRGB }, +{ "ADOBERGB", V4L2_COLORSPACE_ADOBERGB }, +{ "BT2020", V4L2_COLORSPACE_BT2020 }, +{ "RAW", V4L2_COLORSPACE_RAW }, +{ "DCI_P3", V4L2_COLORSPACE_DCI_P3 }, +}; + +const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(colorspaces); ++i) { + if (colorspaces[i].cs == cs) + return colorspaces[i].name; + } + + return "unknown"; +} + enum v4l2_mbus_pixelcode v4l2_subdev_string_to_pixelcode(const char *string) { unsigned int i; diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 4dee6b1..cf1250d 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -278,6 +278,16 @@ int v4l2_subdev_parse_setup_formats(struct media_device *media, const char *p); const char *v4l2_subdev_pixelcode_to_string(enum v4l2_mbus_pixelcode code); /** + * @brief Convert colorspace to string. + * @param code - input string + * + * Convert colorspace @a to a human-readable string. + * + * @return A pointer to a string on success, NULL on failure. + */ +const char *v4l2_subdev_colorspace_to_string(enum v4l2_colorspace cs); + +/** * @brief Parse string to media bus pixel code. * @param string - nul terminalted string, textual media bus pixel code * -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4l-utils v7 4/7] mediactl: Add media_device creation helpers
Add helper functions that allow for easy instantiation of media_device object basing on whether the media device contains v4l2 subdev with given file descriptor. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 131 +- utils/media-ctl/mediactl.h| 27 + 2 files changed, 156 insertions(+), 2 deletions(-) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 155b65f..d347a40 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -440,8 +441,9 @@ static int media_get_devname_udev(struct udev *udev, return -EINVAL; devnum = makedev(entity->info.v4l.major, entity->info.v4l.minor); - media_dbg(entity->media, "looking up device: %u:%u\n", - major(devnum), minor(devnum)); + if (entity->media) + media_dbg(entity->media, "looking up device: %u:%u\n", + major(devnum), minor(devnum)); device = udev_device_new_from_devnum(udev, 'c', devnum); if (device) { p = udev_device_get_devnode(device); @@ -523,6 +525,7 @@ static int media_get_devname_sysfs(struct media_entity *entity) return 0; } + static int media_enum_entities(struct media_device *media) { struct media_entity *entity; @@ -707,6 +710,92 @@ struct media_device *media_device_new(const char *devnode) return media; } +struct media_device *media_device_new_by_subdev_fd(int fd, struct media_entity **fd_entity) +{ + char video_devname[32], device_dir_path[256], media_dev_path[256], media_major_minor[10]; + struct media_device *media = NULL; + struct dirent *entry; + struct media_entity tmp_entity; + DIR *device_dir; + struct udev *udev; + char *p; + int ret, i; + + if (fd_entity == NULL) + return NULL; + + ret = media_get_devname_by_fd(fd, video_devname); + if (ret < 0) + return NULL; + + p = strrchr(video_devname, '/'); + if (p == NULL) + return NULL; + + ret = media_udev_open(&udev); + if (ret < 0) + return NULL; + + sprintf(device_dir_path, "/sys/class/video4linux/%s/device/", p + 1); + + device_dir = opendir(device_dir_path); + if (device_dir == NULL) + return NULL; + + while ((entry = readdir(device_dir))) { + if (strncmp(entry->d_name, "media", 4)) + continue; + + sprintf(media_dev_path, "%s%s/dev", device_dir_path, entry->d_name); + + fd = open(media_dev_path, O_RDONLY); + if (fd < 0) + continue; + + ret = read(fd, media_major_minor, sizeof(media_major_minor)); + if (ret < 0) + continue; + + sscanf(media_major_minor, "%d:%d", &tmp_entity.info.dev.major, &tmp_entity.info.dev.minor); + + /* Try to get the device name via udev */ + if (media_get_devname_udev(udev, &tmp_entity)) { + /* Fall back to get the device name via sysfs */ + if (media_get_devname_sysfs(&tmp_entity)) + continue; + } + + media = media_device_new(tmp_entity.devname); + if (media == NULL) + continue; + + ret = media_device_enumerate(media); + if (ret < 0) { + media_dbg(media, "Failed to enumerate %s (%d)\n", + tmp_entity.devname, ret); + media_device_unref(media); + media = NULL; + continue; + } + + /* Get the entity associated with given fd */ + for (i = 0; i < media->entities_count; i++) { + struct media_entity *entity = &media->entities[i]; + + if (!strcmp(entity->devname, video_devname)) { + *fd_entity = &media->entities[i]; + break; + } + } + + break; + } + + media_udev_close(udev); + + return media; +} + struct media_device *media_device_new_emulated(struct media_device_info *info) { struct media_device *media; @@ -748,6 +837,44 @@ void media_device_unref(struct media_device *media) free(media); } +int media_get_devname_by_fd(int fd, char *node_name) +{ + struct udev *udev; + struct media_entity tmp_entity; + struct stat stat;
[PATCH v4l-utils v7 3/7] mediactl: Add media_entity_get_backlinks()
Add a new graph helper useful for discovering video pipeline. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libmediactl.c | 21 + utils/media-ctl/mediactl.h| 15 +++ 2 files changed, 36 insertions(+) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 91ed003..155b65f 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -36,6 +36,7 @@ #include #include +#include #include #include "mediactl.h" @@ -172,6 +173,26 @@ const struct media_entity_desc *media_entity_get_info(struct media_entity *entit return &entity->info; } +int media_entity_get_backlinks(struct media_entity *entity, + struct media_link **backlinks, + unsigned int *num_backlinks) +{ + unsigned int num_bklinks = 0; + int i; + + if (entity == NULL || backlinks == NULL || num_backlinks == NULL) + return -EINVAL; + + for (i = 0; i < entity->num_links; ++i) + if ((entity->links[i].flags & MEDIA_LNK_FL_ENABLED) && + (entity->links[i].sink->entity == entity)) + backlinks[num_bklinks++] = &entity->links[i]; + + *num_backlinks = num_bklinks; + + return 0; +} + /* - * Open/close */ diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h index 336cbf9..b1f33cd 100644 --- a/utils/media-ctl/mediactl.h +++ b/utils/media-ctl/mediactl.h @@ -434,6 +434,20 @@ int media_parse_setup_link(struct media_device *media, int media_parse_setup_links(struct media_device *media, const char *p); /** + * @brief Get entity's enabled backlinks + * @param entity - media entity. + * @param backlinks - array of pointers to matching backlinks. + * @param num_backlinks - number of matching backlinks. + * + * Get links that are connected to the entity sink pads. + * + * @return 0 on success, or a negative error code on failure. + */ +int media_entity_get_backlinks(struct media_entity *entity, + struct media_link **backlinks, + unsigned int *num_backlinks); + +/** * @brief Get v4l2_subdev for the entity * @param entity - media entity * @@ -443,4 +457,5 @@ int media_parse_setup_links(struct media_device *media, const char *p); */ struct v4l2_subdev *media_entity_get_v4l2_subdev(struct media_entity *entity); + #endif -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4l-utils v7 1/7] mediactl: Add support for v4l2-ctrl-binding config
Make struct v4l2_subdev capable of aggregating v4l2-ctrl-bindings - media device configuration entries. Added are also functions for validating support for the control on given media entity and checking whether a v4l2-ctrl-binding has been defined for a media entity. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- utils/media-ctl/libv4l2subdev.c | 32 utils/media-ctl/v4l2subdev.h| 19 +++ 2 files changed, 51 insertions(+) diff --git a/utils/media-ctl/libv4l2subdev.c b/utils/media-ctl/libv4l2subdev.c index c3439d7..4f8ee7f 100644 --- a/utils/media-ctl/libv4l2subdev.c +++ b/utils/media-ctl/libv4l2subdev.c @@ -50,7 +50,15 @@ int v4l2_subdev_create(struct media_entity *entity) entity->sd->fd = -1; + entity->sd->v4l2_ctrl_bindings = malloc(sizeof(__u32)); + if (entity->sd->v4l2_ctrl_bindings == NULL) + goto err_v4l2_ctrl_bindings_alloc; + return 0; + +err_v4l2_ctrl_bindings_alloc: + free(entity->sd); + return -ENOMEM; } int v4l2_subdev_create_opened(struct media_entity *entity, int fd) @@ -102,6 +110,7 @@ void v4l2_subdev_close(struct media_entity *entity) if (entity->sd->fd_owner) close(entity->sd->fd); + free(entity->sd->v4l2_ctrl_bindings); free(entity->sd); } @@ -884,3 +893,26 @@ const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list(unsigned int *length) return mbus_codes; } + +int v4l2_subdev_supports_v4l2_ctrl(struct media_device *media, + struct media_entity *entity, + __u32 ctrl_id) +{ + struct v4l2_queryctrl queryctrl = {}; + int ret; + + ret = v4l2_subdev_open(entity); + if (ret < 0) + return ret; + + queryctrl.id = ctrl_id; + + ret = ioctl(entity->sd->fd, VIDIOC_QUERYCTRL, &queryctrl); + if (ret < 0) + return ret; + + media_dbg(media, "Validated control \"%s\" (0x%8.8x) on entity %s\n", + queryctrl.name, queryctrl.id, entity->info.name); + + return 0; +} diff --git a/utils/media-ctl/v4l2subdev.h b/utils/media-ctl/v4l2subdev.h index 011fab1..4dee6b1 100644 --- a/utils/media-ctl/v4l2subdev.h +++ b/utils/media-ctl/v4l2subdev.h @@ -26,10 +26,14 @@ struct media_device; struct media_entity; +struct media_device; struct v4l2_subdev { int fd; unsigned int fd_owner:1; + + __u32 *v4l2_ctrl_bindings; + unsigned int num_v4l2_ctrl_bindings; }; /** @@ -314,4 +318,19 @@ enum v4l2_field v4l2_subdev_string_to_field(const char *string); const enum v4l2_mbus_pixelcode *v4l2_subdev_pixelcode_list( unsigned int *length); +/** + * @brief Check if sub-device supports given v4l2 control + * @param media - media device. + * @param entity - media entity. + * @param ctrl_id - id of the v4l2 control to check. + * + * Verify if the sub-device associated with given media entity + * supports v4l2-control with given ctrl_id. + * + * @return 1 if the control is supported, 0 otherwise. + */ +int v4l2_subdev_supports_v4l2_ctrl(struct media_device *device, + struct media_entity *entity, + __u32 ctrl_id); + #endif -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v4l-utils v7 0/7] Add a plugin for Exynos4 camera
This is a seventh version of the patch series adding a plugin for the Exynos4 camera. Last version [0] of the patch set was posted in January. The plugin doesn't link against libmediactl, but has its sources compiled in. Currently utils are built after the plugins, but libv4l-exynos4-camera plugin depends on the utils. In order to link the plugin against libmediactl the build system would have to be modified. Changes from v6: - close v4l2 sub-devices on media device release - moved non-generic code from libmediactl to the plugin - resigned from adding libmedia_ioctl library and moved all its code to the plugin, since it depended on pipeline representation, which was not generic for all possible media device topologies - used media_get_info()->name instead of adding media_entity_get_name - renamed media_get_backlinks_by_entity() to media_entity_get_backlinks(() - moved pipeline from struct media_device to the plugin - changed the way of associating video device file descriptor with media device - switched to using auto-generated media-bus-format-names.h header file - renamed v4l2-ctrl-redir config entry name to v4l2-ctrl-binding Changes from v5: - fixed and tested use cases with S5K6A3 sensor and FIMC-IS-ISP - added conversion "colorspace id to string" Changes from v4: - removed some redundant functions for traversing media device graph and switched over to using existing ones - avoided accessing struct v4l2_subdev from libmediactl - applied various improvements Changes from v3: - added struct v4l2_subdev and put entity fd and information about supported controls to it - improved functions for negotiating and setting pipeline format by using available libv4lsubdev API - applied minor improvements and cleanups Changes from v2: - switched to using mediatext library for parsing the media device configuration - extended libmediactl - switched to using libmediactl Changes from v1: - removed redundant mbus code negotiation - split the parser, media device helpers and ioctl wrappers to the separate modules - added mechanism for querying extended controls - applied various fixes and modifications The plugin was tested on v4.8-rc2 (exynos4-is driver doesn't proble properly with current master branch of linux-media.git) with patches fixing several issues for Exynos4 camera: [1], [2], [3]. The plugin expects a configuration file: /var/lib/libv4l/exynos4_capture_conf Exemplary configuration file for pipeline with sensor S5C73M3 (rear camera): == link-conf "s5p-mipi-csis.0":1 -> "FIMC.0":0 [1] v4l2-ctrl-binding 0x0098091f -> "fimc.0.capture" v4l2-ctrl-binding 0x00980902 -> "S5C73M3" v4l2-ctrl-binding 0x00980922 -> "fimc.0.capture" v4l2-ctrl-binding 0x009a0914 -> "S5C73M3" == With this settings the plugin can be tested on the exynos4412-trats2 board using following gstreamer pipeline: gst-launch-1.0 v4l2src device=/dev/video1 extra-controls="c,rotate=90,color_effects=2" ! video/x-raw,width=960,height=720 ! fbdevsink Exemplary configuration file for pipeline with sensor S5K6A3 (front camera): == link-conf "s5p-mipi-csis.1":1 -> "FIMC-LITE.1":0 [1] link-conf "FIMC-LITE.1":2 -> "FIMC-IS-ISP":0 [1] link-conf "FIMC-IS-ISP":1 -> "FIMC.0":1 [1] == gst-launch-1.0 v4l2src device=/dev/video1 extra-controls="c,rotate=270,color_effects=2,horizontal_flip=1" ! video/x-raw,width=960,height=920 ! fbdevsink Best Regards, Jacek Anaszewski [0] http://www.spinics.net/lists/linux-media/msg96510.html [1] https://patchwork.kernel.org/patch/9335197/ [2] https://patchwork.kernel.org/patch/9270985/ [3] https://patchwork.kernel.org/patch/9308923/ [4] https://patchwork.kernel.org/patch/9335273/ Jacek Anaszewski (7): mediactl: Add support for v4l2-ctrl-binding config mediatext: Add library mediactl: Add media_entity_get_backlinks() mediactl: Add media_device creation helpers mediactl: libv4l2subdev: Add colorspace logging mediactl: libv4l2subdev: add support for comparing mbus formats Add a libv4l plugin for Exynos4 camera configure.ac |1 + lib/Makefile.am |5 + lib/libv4l-exynos4-camera/Makefile.am | 19 + lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 1325 + utils/media-ctl/Makefile.am | 10 +- utils/media-ctl/libmediactl.c | 152 ++- utils/media-ctl/libmediate
[PATCH v4l-utils 7/7 v7.1] Add a libv4l plugin for Exynos4 camera
The plugin provides support for the media device on Exynos4 SoC. It performs single plane <-> multi plane API conversion, video pipeline linking and takes care of automatic data format negotiation for the whole pipeline, after intercepting VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- configure.ac |1 + lib/Makefile.am |5 + lib/libv4l-exynos4-camera/Makefile.am | 19 + lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c | 1335 + 4 files changed, 1360 insertions(+) create mode 100644 lib/libv4l-exynos4-camera/Makefile.am create mode 100644 lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c diff --git a/configure.ac b/configure.ac index 8447f05..692718a 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AC_CONFIG_FILES([Makefile lib/libdvbv5/Makefile lib/libv4l2rds/Makefile lib/libv4l-mplane/Makefile + lib/libv4l-exynos4-camera/Makefile utils/Makefile utils/libv4l2util/Makefile diff --git a/lib/Makefile.am b/lib/Makefile.am index a105c95..b5e52db 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -5,6 +5,11 @@ SUBDIRS = \ libv4l2rds \ libv4l-mplane +if WITH_V4LUTILS +SUBDIRS += \ + libv4l-exynos4-camera +endif + if WITH_LIBDVBV5 SUBDIRS += \ libdvbv5 diff --git a/lib/libv4l-exynos4-camera/Makefile.am b/lib/libv4l-exynos4-camera/Makefile.am new file mode 100644 index 000..c38b7f6 --- /dev/null +++ b/lib/libv4l-exynos4-camera/Makefile.am @@ -0,0 +1,19 @@ +if WITH_V4L_PLUGINS +libv4l2plugin_LTLIBRARIES = libv4l-exynos4-camera.la +endif + +media-bus-format-names.h: ../../include/linux/media-bus-format.h + sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*FMT_//; /FIXED/ d; s/\t.*//; s/.*/{ \"&\", MEDIA_BUS_FMT_& },/;' \ + < $< > $@ + +media-bus-format-codes.h: ../../include/linux/media-bus-format.h + sed -e '/#define MEDIA_BUS_FMT/ ! d; s/.*#define //; /FIXED/ d; s/\t.*//; s/.*/ &,/;' \ + < $< > $@ + +BUILT_SOURCES = media-bus-format-names.h media-bus-format-codes.h +CLEANFILES = $(BUILT_SOURCES) + +nodist_libv4l_exynos4_camera_la_SOURCES = $(BUILT_SOURCES) +libv4l_exynos4_camera_la_SOURCES = libv4l-exynos4-camera.c ../../utils/media-ctl/libmediactl.c ../../utils/media-ctl/libv4l2subdev.c ../../utils/media-ctl/mediatext.c +libv4l_exynos4_camera_la_CFLAGS = -fvisibility=hidden -std=gnu99 +libv4l_exynos4_camera_la_LDFLAGS = -avoid-version -module -shared -export-dynamic -lpthread diff --git a/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c new file mode 100644 index 000..c2c4c6e --- /dev/null +++ b/lib/libv4l-exynos4-camera/libv4l-exynos4-camera.c @@ -0,0 +1,1335 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Author: Jacek Anaszewski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../utils/media-ctl/mediactl.h" +#include "../../utils/media-ctl/mediatext.h" +#include "../../utils/media-ctl/v4l2subdev.h" +#include "libv4l-plugin.h" + +#define DEBUG +#ifdef DEBUG +#define V4L2_EXYNOS4_DBG(format, ARG...)\ + printf("[%s:%d] [%s] " format " \n", __FILE__, __LINE__, __func__, ##ARG) +#else +#define V4L2_EXYNOS4_DBG(format, ARG...) +#endif + +#define V4L2_EXYNOS4_ERR(format, ARG...)\ + fprintf(stderr, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG) + +#define V4L2_EXYNOS4_LOG(format, ARG...)\ + fprintf(stdout, "Libv4l Exynos4 camera plugin: "format "\n", ##ARG) + +#define VIDIOC_CTRL(type) \ + ((type) == VIDIOC_S_CTRL ? "VIDIOC_S_CTRL" :\ + "VIDIOC_G_CTRL") + +#define VIDIOC_EXT_CTRL(type) \ + ((type) == VIDIOC_S_EXT_CTRLS ? \ + "VIDIOC_S_EXT_CTRLS": \ + ((type) == VIDIOC_G_EXT_CTRLS ?\ + "VIDIOC_G_EXT_CTRLS" : \ +
Re: [PATCH v4l-utils 7/7 v7.1] Add a libv4l plugin for Exynos4 camera
Forgot to add changelog: Changes since v7: - fixed and improved ctrl ioctl handlers Best regards, Jacek Anaszewski On 10/13/2016 04:19 PM, Jacek Anaszewski wrote: The plugin provides support for the media device on Exynos4 SoC. It performs single plane <-> multi plane API conversion, video pipeline linking and takes care of automatic data format negotiation for the whole pipeline, after intercepting VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctls. Signed-off-by: Jacek Anaszewski Acked-by: Kyungmin Park --- -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 00/16] Add support for Exynox4x12 to the s5p-jpeg driver
The main aim of this series is to add support for Exynos4x12 SoC for the s5p-jpeg driver. Nonetheless, a room for couple of fixes and improvements has been found during development, which is reflected in the corresponding patches. Thanks, Jacek Anaszewski Jacek Anaszewski (16): s5p-jpeg: Reorder quantization tables s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder s5p-jpeg: Fix erroneous condition while validating bytesperline value s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly s5p-jpeg: Fix clock resource management s5p-jpeg: Fix lack of spin_lock protection s5p-jpeg: Synchronize cached controls with V4L2 core s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec. s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header s5p-jpeg: Ensure correct capture format for Exynos4x12 s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value s5p-jpeg: Ensure setting correct value of the chroma subsampling control s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c| 1049 drivers/media/platform/s5p-jpeg/jpeg-core.h| 75 +- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c | 293 ++ drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h | 44 + .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 +- drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h| 215 +++- 8 files changed, 1564 insertions(+), 259 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/16] s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder
Output samples during decoding phase for the YUV 4:2:0 format are arranged in the manner compatible with 2-planar NV12, not 3-planar YUV420 fourcc. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 2234944..0f567c5 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -58,7 +58,7 @@ static struct s5p_jpeg_fmt formats_enc[] = { static struct s5p_jpeg_fmt formats_dec[] = { { .name = "YUV 4:2:0 planar, YCbCr", - .fourcc = V4L2_PIX_FMT_YUV420, + .fourcc = V4L2_PIX_FMT_NV12, .depth = 12, .colplanes = 3, .h_align= 4, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01/16] s5p-jpeg: Reorder quantization tables
Reorder quantization tables so that their elements are arranged in the manner reflecting compression quality level that is in accordance with V4L2 documentation, i.e. the larger value of the V4L2_CID_JPEG_COMPRESSION_QUALITY control the better image quality, and thus lower compression quality. The modification allows also to get rid of reverse logic in the s_ctrl callback while assigning user space value to the ctx->compr_quality variable. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 116 +-- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 47934db..2234944 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -84,15 +84,25 @@ static struct s5p_jpeg_fmt formats_dec[] = { #define NUM_FORMATS_DEC ARRAY_SIZE(formats_dec) static const unsigned char qtbl_luminance[4][64] = { - {/* level 1 - high quality */ -8, 6, 6, 8, 12, 14, 16, 17, -6, 6, 6, 8, 10, 13, 12, 15, -6, 6, 7, 8, 13, 14, 18, 24, -8, 8, 8, 14, 13, 19, 24, 35, - 12, 10, 13, 13, 20, 26, 34, 39, - 14, 13, 14, 19, 26, 34, 39, 39, - 16, 12, 18, 24, 34, 39, 39, 39, - 17, 15, 24, 35, 39, 39, 39, 39 + {/*level 0 - high compression quality */ + 20, 16, 25, 39, 50, 46, 62, 68, + 16, 18, 23, 38, 38, 53, 65, 68, + 25, 23, 31, 38, 53, 65, 68, 68, + 39, 38, 38, 53, 65, 68, 68, 68, + 50, 38, 53, 65, 68, 68, 68, 68, + 46, 53, 65, 68, 68, 68, 68, 68, + 62, 65, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68 + }, + {/* level 1 */ + 16, 11, 11, 16, 23, 27, 31, 30, + 11, 12, 12, 15, 20, 23, 23, 30, + 11, 12, 13, 16, 23, 26, 35, 47, + 16, 15, 16, 23, 26, 37, 47, 64, + 23, 20, 23, 26, 39, 51, 64, 64, + 27, 23, 26, 37, 51, 64, 64, 64, + 31, 23, 35, 47, 64, 64, 64, 64, + 30, 30, 47, 64, 64, 64, 64, 64 }, {/* level 2 */ 12, 8, 8, 12, 17, 21, 24, 23, @@ -104,38 +114,38 @@ static const unsigned char qtbl_luminance[4][64] = { 24, 18, 27, 36, 51, 59, 59, 59, 23, 23, 36, 53, 59, 59, 59, 59 }, - {/* level 3 */ - 16, 11, 11, 16, 23, 27, 31, 30, - 11, 12, 12, 15, 20, 23, 23, 30, - 11, 12, 13, 16, 23, 26, 35, 47, - 16, 15, 16, 23, 26, 37, 47, 64, - 23, 20, 23, 26, 39, 51, 64, 64, - 27, 23, 26, 37, 51, 64, 64, 64, - 31, 23, 35, 47, 64, 64, 64, 64, - 30, 30, 47, 64, 64, 64, 64, 64 - }, - {/*level 4 - low quality */ - 20, 16, 25, 39, 50, 46, 62, 68, - 16, 18, 23, 38, 38, 53, 65, 68, - 25, 23, 31, 38, 53, 65, 68, 68, - 39, 38, 38, 53, 65, 68, 68, 68, - 50, 38, 53, 65, 68, 68, 68, 68, - 46, 53, 65, 68, 68, 68, 68, 68, - 62, 65, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68 + {/* level 3 - low compression quality */ +8, 6, 6, 8, 12, 14, 16, 17, +6, 6, 6, 8, 10, 13, 12, 15, +6, 6, 7, 8, 13, 14, 18, 24, +8, 8, 8, 14, 13, 19, 24, 35, + 12, 10, 13, 13, 20, 26, 34, 39, + 14, 13, 14, 19, 26, 34, 39, 39, + 16, 12, 18, 24, 34, 39, 39, 39, + 17, 15, 24, 35, 39, 39, 39, 39 } }; static const unsigned char qtbl_chrominance[4][64] = { - {/* level 1 - high quality */ -9, 8, 9, 11, 14, 17, 19, 24, -8, 10, 9, 11, 14, 13, 17, 22, -9, 9, 13, 14, 13, 15, 23, 26, - 11, 11, 14, 14, 15, 20, 26, 33, - 14, 14, 13, 15, 20, 24, 33, 39, - 17, 13, 15, 20, 24, 32, 39, 39, - 19, 17, 23, 26, 33, 39, 39, 39, - 24, 22, 26, 33, 39, 39, 39, 39 + {/*level 0 - high compression quality */ + 21, 25, 32, 38, 54, 68, 68, 68, + 25, 28, 24, 38, 54, 68, 68, 68, + 32, 24, 32, 43, 66, 68, 68, 68, + 38, 38, 43, 53, 68, 68, 68, 68, + 54, 54, 66, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68 + }, + {/* level 1 */ + 17, 15, 17, 21, 20, 26, 38, 48, + 15, 19, 18, 17, 20, 26, 35, 43, + 17, 18, 20, 22, 26, 30, 46, 53, + 21, 17, 22, 28, 30, 39, 53,
[PATCH 03/16] s5p-jpeg: Fix erroneous condition while validating bytesperline value
The aim of the condition is ensuring that the bytesperline value set by the user space application is proper for the given format and adjusting it if isn't. As the depth value of the format description entry is expressed in bits then the bytesperline value needs to be divided, not multiplied, by that value to get the number of bytes required to store single line of image samples. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 0f567c5..a1366f0 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -670,7 +670,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt, bpl = pix->width; /* planar */ if (fmt->colplanes == 1 && /* packed */ - (bpl << 3) * fmt->depth < pix->width) + (bpl << 3) / fmt->depth < pix->width) bpl = (pix->width * fmt->depth) >> 3; pix->bytesperline = bpl; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 13/16] s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder
Exynos4x12 supports wider scope of subsampling modes than S5PC210. Adjust corresponding mask accordingly. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 15b2dea..319be0c 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1210,7 +1210,8 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx) v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops, V4L2_CID_JPEG_RESTART_INTERVAL, 0, 3, 0x, 0); - mask = ~0x06; /* 422, 420 */ + if (ctx->jpeg->variant->version == SJPEG_S5P) + mask = ~0x06; /* 422, 420 */ } ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07/16] s5p-jpeg: Fix lack of spin_lock protection
s5p_jpeg_device_run and s5p_jpeg_runtime_resume callbacks should have spin_lock protection as they alter device registers. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 328bb8b..650c4d3 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -930,7 +930,9 @@ static void s5p_jpeg_device_run(void *priv) struct s5p_jpeg_ctx *ctx = priv; struct s5p_jpeg *jpeg = ctx->jpeg; struct vb2_buffer *src_buf, *dst_buf; - unsigned long src_addr, dst_addr; + unsigned long src_addr, dst_addr, flags; + + spin_lock_irqsave(&ctx->jpeg->slock, flags); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); @@ -998,6 +1000,8 @@ static void s5p_jpeg_device_run(void *priv) } jpeg_start(jpeg->regs); + + spin_unlock_irqrestore(&ctx->jpeg->slock, flags); } static int s5p_jpeg_job_ready(void *priv) @@ -1418,9 +1422,12 @@ static int s5p_jpeg_runtime_suspend(struct device *dev) static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + unsigned long flags; clk_prepare_enable(jpeg->clk); + spin_lock_irqsave(&jpeg->slock, flags); + /* * JPEG IP allows storing two Huffman tables for each component * We fill table 0 for each component @@ -1430,6 +1437,8 @@ static int s5p_jpeg_runtime_resume(struct device *dev) s5p_jpeg_set_hactbl(jpeg->regs); s5p_jpeg_set_hactblg(jpeg->regs); + spin_unlock_irqrestore(&jpeg->slock, flags); + return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/16] s5p-jpeg: Fix clock resource management
Standard suspend/resume path is called after runtime resume of the given device, so suspend/resume callbacks must do all clock management done also by runtime pm to allow for proper power domain shutdown. Moreover, JPEG clock is enabled from probe function but is is not necessary. This patch also moves control of jpeg clock to runtime_pm callbacks. Signed-off-by: Marek Szyprowski Signed-off-by: Seung-Woo Kim Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 52 ++- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 32033e7..328bb8b 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1250,29 +1250,28 @@ static int s5p_jpeg_probe(struct platform_device *pdev) if (IS_ERR(jpeg->regs)) return PTR_ERR(jpeg->regs); + /* clocks */ + jpeg->clk = clk_get(&pdev->dev, "jpeg"); + if (IS_ERR(jpeg->clk)) { + dev_err(&pdev->dev, "cannot get clock\n"); + ret = PTR_ERR(jpeg->clk); + return ret; + } + dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); + /* interrupt service routine registration */ jpeg->irq = ret = platform_get_irq(pdev, 0); if (ret < 0) { dev_err(&pdev->dev, "cannot find IRQ\n"); - return ret; + goto clk_get_rollback; } ret = devm_request_irq(&pdev->dev, jpeg->irq, s5p_jpeg_irq, 0, dev_name(&pdev->dev), jpeg); if (ret) { dev_err(&pdev->dev, "cannot claim IRQ %d\n", jpeg->irq); - return ret; - } - - /* clocks */ - jpeg->clk = clk_get(&pdev->dev, "jpeg"); - if (IS_ERR(jpeg->clk)) { - dev_err(&pdev->dev, "cannot get clock\n"); - ret = PTR_ERR(jpeg->clk); - return ret; + goto clk_get_rollback; } - dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); - clk_prepare_enable(jpeg->clk); /* v4l2 device */ ret = v4l2_device_register(&pdev->dev, &jpeg->v4l2_dev); @@ -1380,7 +1379,6 @@ device_register_rollback: v4l2_device_unregister(&jpeg->v4l2_dev); clk_get_rollback: - clk_disable_unprepare(jpeg->clk); clk_put(jpeg->clk); return ret; @@ -1400,7 +1398,9 @@ static int s5p_jpeg_remove(struct platform_device *pdev) v4l2_m2m_release(jpeg->m2m_dev); v4l2_device_unregister(&jpeg->v4l2_dev); - clk_disable_unprepare(jpeg->clk); + if (!pm_runtime_status_suspended(&pdev->dev)) + clk_disable_unprepare(jpeg->clk); + clk_put(jpeg->clk); return 0; @@ -1408,6 +1408,10 @@ static int s5p_jpeg_remove(struct platform_device *pdev) static int s5p_jpeg_runtime_suspend(struct device *dev) { + struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + + clk_disable_unprepare(jpeg->clk); + return 0; } @@ -1415,6 +1419,8 @@ static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + clk_prepare_enable(jpeg->clk); + /* * JPEG IP allows storing two Huffman tables for each component * We fill table 0 for each component @@ -1427,9 +1433,23 @@ static int s5p_jpeg_runtime_resume(struct device *dev) return 0; } +static int s5p_jpeg_suspend(struct device *dev) +{ + s5p_jpeg_runtime_suspend(dev); + + return 0; +} + +static int s5p_jpeg_resume(struct device *dev) +{ + s5p_jpeg_runtime_resume(dev); + + return 0; +} + static const struct dev_pm_ops s5p_jpeg_pm_ops = { - .runtime_suspend = s5p_jpeg_runtime_suspend, - .runtime_resume = s5p_jpeg_runtime_resume, + SET_SYSTEM_SLEEP_PM_OPS(s5p_jpeg_suspend, s5p_jpeg_resume) + SET_RUNTIME_PM_OPS(s5p_jpeg_runtime_suspend, s5p_jpeg_runtime_resume, NULL) }; #ifdef CONFIG_OF -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 14/16] s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value
When output queue fourcc is set to any flavour of YUV, the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value as well as its in-driver cached counterpart have to be updated with the subsampling property of the format so as to be able to provide correct information to the user space and preclude setting an illegal subsampling mode for Exynos4x12 encoder. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |5 + 1 file changed, 5 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 319be0c..d4db612 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1038,6 +1038,7 @@ static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv, { struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); struct s5p_jpeg_fmt *fmt; + struct v4l2_control ctrl_subs; fmt = s5p_jpeg_find_format(ctx, f->fmt.pix.pixelformat, FMT_TYPE_OUTPUT); @@ -1048,6 +1049,10 @@ static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv, return -EINVAL; } + ctrl_subs.id = V4L2_CID_JPEG_CHROMA_SUBSAMPLING; + ctrl_subs.value = fmt->subsampling; + v4l2_s_ctrl(priv, &ctx->ctrl_handler, &ctrl_subs); + return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_OUTPUT); } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/16] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
Move function definitions from jpeg-hw.h to jpeg-hw-s5p.c and put function declarations in the jpeg-hw-s5p.h. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c|2 +- drivers/media/platform/s5p-jpeg/jpeg-core.h|5 ++ .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 +++ 5 files changed, 104 insertions(+), 50 deletions(-) rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h diff --git a/drivers/media/platform/s5p-jpeg/Makefile b/drivers/media/platform/s5p-jpeg/Makefile index d18cb5e..faf6398 100644 --- a/drivers/media/platform/s5p-jpeg/Makefile +++ b/drivers/media/platform/s5p-jpeg/Makefile @@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index b82e3fa..4e874ad 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -29,7 +29,7 @@ #include #include "jpeg-core.h" -#include "jpeg-hw.h" +#include "jpeg-hw-s5p.h" static struct s5p_jpeg_fmt formats_enc[] = { { diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h index 4a4776b..7baadf3 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h @@ -42,10 +42,15 @@ #define EOI0xd9 #define DHP0xde +#define S5P_JPEG_ENCODE0 +#define S5P_JPEG_DECODE1 + /* Flags that indicate a format can be used for capture/output */ #define MEM2MEM_CAPTURE(1 << 0) #define MEM2MEM_OUTPUT (1 << 1) + + /** * struct s5p_jpeg - JPEG IP abstraction * @lock: the mutex protecting this structure diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw.h b/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c similarity index 71% rename from drivers/media/platform/s5p-jpeg/jpeg-hw.h rename to drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c index b47e887..6a1164c 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-hw.h +++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c @@ -9,27 +9,15 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#ifndef JPEG_HW_H_ -#define JPEG_HW_H_ #include #include -#include "jpeg-hw.h" +#include "jpeg-core.h" #include "jpeg-regs.h" +#include "jpeg-hw-s5p.h" -#define S5P_JPEG_MIN_WIDTH 32 -#define S5P_JPEG_MIN_HEIGHT32 -#define S5P_JPEG_MAX_WIDTH 8192 -#define S5P_JPEG_MAX_HEIGHT8192 -#define S5P_JPEG_ENCODE0 -#define S5P_JPEG_DECODE1 -#define S5P_JPEG_RAW_IN_5650 -#define S5P_JPEG_RAW_IN_4221 -#define S5P_JPEG_RAW_OUT_422 0 -#define S5P_JPEG_RAW_OUT_420 1 - -static inline void jpeg_reset(void __iomem *regs) +void jpeg_reset(void __iomem *regs) { unsigned long reg; @@ -42,12 +30,12 @@ static inline void jpeg_reset(void __iomem *regs) } } -static inline void jpeg_poweron(void __iomem *regs) +void jpeg_poweron(void __iomem *regs) { writel(S5P_POWER_ON, regs + S5P_JPGCLKCON); } -static inline void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode) +void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode) { unsigned long reg, m; @@ -63,7 +51,7 @@ static inline void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode) writel(reg, regs + S5P_JPGCMOD); } -static inline void jpeg_input_raw_y16(void __iomem *regs, bool y16) +void jpeg_input_raw_y16(void __iomem *regs, bool y16) { unsigned long reg; @@ -75,7 +63,7 @@ static inline void jpeg_input_raw_y16(void __iomem *regs, bool y16) writel(reg, regs + S5P_JPGCMOD); } -static inline void jpeg_proc_mode(void __iomem *regs, unsigned long mode) +void jpeg_proc_mode(void __iomem *regs, unsigned long mode) { unsigned long reg, m; @@ -90,7 +78,7 @@ static inline void jpeg_proc_mode(void __iomem *regs, unsigned long mode) writel(reg, regs + S5P_JPGMOD); } -static inline void jpeg_subsampling_mode(void __iomem *regs, unsigned int mode) +void jpeg_subsampling_mode(void __iomem *regs, unsigned int mode) { unsigned long reg, m; @@ -105,12 +93,12 @@ static inline void jpeg_subsampling_mode(void __iomem *regs, unsigned int mode) writel(reg, regs + S5
[PATCH 11/16] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
Make s5p_jpeg_parse_hdr function capable of parsing "YCbCr subsampling" field of a jpeg file header. Store the parsed value in the context. The information about source JPEG subsampling is required to make validation of destination format possible, which must be conducted for exynos4x12 device as the decoding process will not succeed if the destination format is set to YUV with subsampling lower than the one of the source JPEG image. With this knowledge the driver can adjust the destination format appropriately. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 --- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 68a82cc..e09b03a 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -624,10 +624,11 @@ static void skip(struct s5p_jpeg_buffer *buf, long len) } static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, - unsigned long buffer, unsigned long size) + unsigned long buffer, unsigned long size, + struct s5p_jpeg_ctx *ctx) { int c, components, notfound; - unsigned int height, width, word; + unsigned int height, width, word, subsampling = 0; long length; struct s5p_jpeg_buffer jpeg_buffer; @@ -666,7 +667,15 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, break; notfound = 0; - skip(&jpeg_buffer, components * 3); + if (components == 1) { + subsampling = 0x33; + } else { + skip(&jpeg_buffer, 1); + subsampling = get_byte(&jpeg_buffer); + skip(&jpeg_buffer, 1); + } + + skip(&jpeg_buffer, components * 2); break; /* skip payload-less markers */ @@ -688,6 +697,24 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, result->w = width; result->h = height; result->size = components; + + switch (subsampling) { + case 0x11: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444; + break; + case 0x21: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422; + break; + case 0x22: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420; + break; + case 0x33: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; + break; + default: + return false; + } + return !notfound; } @@ -1426,7 +1453,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp, (unsigned long)vb2_plane_vaddr(vb, 0), min((unsigned long)ctx->out_q.size, -vb2_get_plane_payload(vb, 0))); +vb2_get_plane_payload(vb, 0)), ctx); if (!ctx->hdr_parsed) { vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); return; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/16] s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec.
Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c | 620 +++--- drivers/media/platform/s5p-jpeg/jpeg-core.h | 72 ++- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c | 293 ++ drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h | 44 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h | 215 +++- 6 files changed, 1152 insertions(+), 94 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h diff --git a/drivers/media/platform/s5p-jpeg/Makefile b/drivers/media/platform/s5p-jpeg/Makefile index faf6398..f981dff 100644 --- a/drivers/media/platform/s5p-jpeg/Makefile +++ b/drivers/media/platform/s5p-jpeg/Makefile @@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-exynos.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 4e874ad..68a82cc 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1,9 +1,10 @@ /* linux/drivers/media/platform/s5p-jpeg/jpeg-core.c * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. * http://www.samsung.com * * Author: Andrzej Pietrasiewicz + * Author: Jacek Anaszewski * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -30,58 +31,212 @@ #include "jpeg-core.h" #include "jpeg-hw-s5p.h" +#include "jpeg-hw-exynos.h" +#include "jpeg-regs.h" -static struct s5p_jpeg_fmt formats_enc[] = { +static struct s5p_jpeg_fmt sjpeg_formats[] = { { .name = "JPEG JFIF", .fourcc = V4L2_PIX_FMT_JPEG, + .flags = SJPEG_FMT_FLAG_ENC_CAPTURE | + SJPEG_FMT_FLAG_DEC_OUTPUT | + SJPEG_FMT_FLAG_S5P | + SJPEG_FMT_FLAG_EXYNOS, + }, + { + .name = "YUV 4:2:2 packed, YCbYCr", + .fourcc = V4L2_PIX_FMT_YUYV, + .depth = 16, .colplanes = 1, - .types = MEM2MEM_CAPTURE, + .h_align= 4, + .v_align= 3, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_S5P | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, }, { .name = "YUV 4:2:2 packed, YCbYCr", .fourcc = V4L2_PIX_FMT_YUYV, .depth = 16, .colplanes = 1, - .types = MEM2MEM_OUTPUT, + .h_align= 1, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, + }, + { + .name = "YUV 4:2:2 packed, YCrYCb", + .fourcc = V4L2_PIX_FMT_YVYU, + .depth = 16, + .colplanes = 1, + .h_align= 1, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, }, { .name = "RGB565", .fourcc = V4L2_PIX_FMT_RGB565, .depth = 16, .colplanes = 1, - .types = MEM2MEM_OUTPUT, + .h_align= 0, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS | + SJPEG_FMT_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_444, + }, + { + .name = "RGB565", + .fourcc = V4L2_PIX_FMT_RGB565,
[PATCH 16/16] s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs
Whereas S5PC210 device produces decoded JPEG subsampling values that map on V4L2_JPEG_CHROMA_SUBSAMPLNG values, the Exynos4x12 device doesn't. This patch adds helper function decoded_subsampling_to_v4l2, which performs HW -> V4L2 translation. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 36 ++- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 3605470..90d2f69 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -358,6 +358,13 @@ static const unsigned char hactblg0[162] = { 0xf9, 0xfa }; +static int exynos4x12_decoded_subsampling[] = { + V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY, + V4L2_JPEG_CHROMA_SUBSAMPLING_444, + V4L2_JPEG_CHROMA_SUBSAMPLING_422, + V4L2_JPEG_CHROMA_SUBSAMPLING_420, +}; + static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c) { return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler); @@ -368,6 +375,28 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh) return container_of(fh, struct s5p_jpeg_ctx, fh); } +static inline int decoded_subsampling_to_v4l2(struct s5p_jpeg_ctx *ctx) +{ + int subsampling; + + WARN_ON(ctx->subsampling > 3); + + if (ctx->jpeg->variant->version == SJPEG_S5P) { + if (ctx->subsampling > 2) + subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; + else + subsampling = ctx->subsampling; + } else { + if (ctx->subsampling > 2) + subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420; + else + subsampling = + exynos4x12_decoded_subsampling[ctx->subsampling]; + } + + return subsampling; +} + static inline void s5p_jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, unsigned long tab, int len) @@ -1159,12 +1188,7 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: spin_lock_irqsave(&jpeg->slock, flags); - - WARN_ON(ctx->subsampling > S5P_SUBSAMPLING_MODE_GRAY); - if (ctx->subsampling > 2) - ctrl->val = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; - else - ctrl->val = ctx->subsampling; + ctrl->val = decoded_subsampling_to_v4l2(ctx); spin_unlock_irqrestore(&jpeg->slock, flags); break; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 15/16] s5p-jpeg: Ensure setting correct value of the chroma subsampling control
Exynos4x12 has limitations regarding setting chroma subsampling of an output JPEG image. It cannot be lower than the subsampling of the raw source image. Also in case of V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY option the source image fourcc has to be V4L2_PIX_FMT_GREY. This patch adds mechanism that prevents setting invalid value of the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 27 +-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index d4db612..3605470 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1176,6 +1176,7 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl) { struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl); unsigned long flags; + int ret = 0; spin_lock_irqsave(&ctx->jpeg->slock, flags); @@ -1187,12 +1188,34 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl) ctx->restart_interval = ctrl->val; break; case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: - ctx->subsampling = ctrl->val; + if (ctx->jpeg->variant->version == SJPEG_S5P) { + ctx->subsampling = ctrl->val; + break; + } + /* +* The exynos4x12 device requires input raw image fourcc +* to be V4L2_PIX_FMT_GREY if gray jpeg format +* is to be set. +*/ + if (ctx->out_q.fmt->fourcc != V4L2_PIX_FMT_GREY && + ctrl->val == V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY) { + ret = -EINVAL; + goto error_free; + } + /* +* The exynos4x12 device requires resulting jpeg subsampling +* not to be lower than the input raw image subsampling. +*/ + if (ctx->out_q.fmt->subsampling > ctrl->val) + ctx->subsampling = ctx->out_q.fmt->subsampling; + else + ctx->subsampling = ctrl->val; break; } +error_free: spin_unlock_irqrestore(&ctx->jpeg->slock, flags); - return 0; + return ret; } static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops = { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 08/16] s5p-jpeg: Synchronize cached controls with V4L2 core
This patch adds proper initialization of the in-driver cached state of JPEG controls with V4L2 core. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 650c4d3..b82e3fa 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -890,6 +890,9 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx) if (ctx->mode == S5P_JPEG_DECODE) ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY; + + v4l2_ctrl_handler_setup(&ctx->ctrl_handler); + return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 12/16] s5p-jpeg: Ensure correct capture format for Exynos4x12
Adjust capture format to the Exynos4x12 device limitations, according to the subsampling value parsed from the source JPEG image header. If the capture format was set to YUV with subsampling lower than the one of the source JPEG image the decoding process would not succeed. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 78 +++ 1 file changed, 78 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index e09b03a..15b2dea 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -941,6 +941,7 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); + struct v4l2_pix_format *pix = &f->fmt.pix; struct s5p_jpeg_fmt *fmt; fmt = s5p_jpeg_find_format(ctx, f->fmt.pix.pixelformat, @@ -952,6 +953,83 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, return -EINVAL; } + /* +* The exynos4x12 device requires resulting YUV image +* subsampling not to be lower than the input jpeg subsampling. +* If this requirement is not met then downgrade the requested +* output format to the one with subsampling equal to the input jpeg. +*/ + if ((ctx->jpeg->variant->version != SJPEG_S5P) && + (ctx->mode == S5P_JPEG_DECODE) && + (fmt->flags & SJPEG_FMT_NON_RGB) && + (fmt->subsampling < ctx->subsampling)) { + switch (fmt->fourcc) { + case V4L2_PIX_FMT_NV24: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_422: + pix->pixelformat = V4L2_PIX_FMT_NV16; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV12; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_NV42: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_422: + pix->pixelformat = V4L2_PIX_FMT_NV61; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV21; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_YUYV: + case V4L2_PIX_FMT_NV16: + case V4L2_PIX_FMT_YUV420: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV12; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_YVYU: + case V4L2_PIX_FMT_NV61: + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + pix->pixelformat = V4L2_PIX_FMT_NV21; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + break; + case V4L2_PIX_FMT_NV12: + case V4L2_PIX_FMT_NV21: + pix->pixelformat = V4L2_PIX_FMT_GREY; + break; + default: + return -EINVAL; + } + } + return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_CAPTURE); } -- 1.7.9.5 -- To unsubscribe from this list: sen
[PATCH 04/16] s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function
Aligning capture queue image dimensions while enqueuing output queue doesn't make a sense as the S_FMT ioctl might have not been called for the capture queue until that moment, whereas it is required to know capture format as the type of alignment heavily depends on it. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |7 --- 1 file changed, 7 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index a1366f0..a6ec8c6 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1089,13 +1089,6 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) q_data = &ctx->cap_q; q_data->w = tmp.w; q_data->h = tmp.h; - - jpeg_bound_align_image(&q_data->w, S5P_JPEG_MIN_WIDTH, - S5P_JPEG_MAX_WIDTH, q_data->fmt->h_align, - &q_data->h, S5P_JPEG_MIN_HEIGHT, - S5P_JPEG_MAX_HEIGHT, q_data->fmt->v_align - ); - q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3; } v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/16] s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly
Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 58 --- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index a6ec8c6..32033e7 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -213,8 +213,9 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh) return container_of(fh, struct s5p_jpeg_ctx, fh); } -static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, - unsigned long tab, int len) +static inline void s5p_jpeg_set_qtbl(void __iomem *regs, +const unsigned char *qtbl, +unsigned long tab, int len) { int i; @@ -222,22 +223,25 @@ static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, writel((unsigned int)qtbl[i], regs + tab + (i * 0x04)); } -static inline void jpeg_set_qtbl_lum(void __iomem *regs, int quality) +static inline void s5p_jpeg_set_qtbl_lum(void __iomem *regs, int quality) { /* this driver fills quantisation table 0 with data for luma */ - jpeg_set_qtbl(regs, qtbl_luminance[quality], S5P_JPG_QTBL_CONTENT(0), - ARRAY_SIZE(qtbl_luminance[quality])); + s5p_jpeg_set_qtbl(regs, qtbl_luminance[quality], + S5P_JPG_QTBL_CONTENT(0), + ARRAY_SIZE(qtbl_luminance[quality])); } -static inline void jpeg_set_qtbl_chr(void __iomem *regs, int quality) +static inline void s5p_jpeg_set_qtbl_chr(void __iomem *regs, int quality) { /* this driver fills quantisation table 1 with data for chroma */ - jpeg_set_qtbl(regs, qtbl_chrominance[quality], S5P_JPG_QTBL_CONTENT(1), - ARRAY_SIZE(qtbl_chrominance[quality])); + s5p_jpeg_set_qtbl(regs, qtbl_chrominance[quality], + S5P_JPG_QTBL_CONTENT(1), + ARRAY_SIZE(qtbl_chrominance[quality])); } -static inline void jpeg_set_htbl(void __iomem *regs, const unsigned char *htbl, - unsigned long tab, int len) +static inline void s5p_jpeg_set_htbl(void __iomem *regs, +const unsigned char *htbl, +unsigned long tab, int len) { int i; @@ -245,28 +249,32 @@ static inline void jpeg_set_htbl(void __iomem *regs, const unsigned char *htbl, writel((unsigned int)htbl[i], regs + tab + (i * 0x04)); } -static inline void jpeg_set_hdctbl(void __iomem *regs) +static inline void s5p_jpeg_set_hdctbl(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hdctbl0, S5P_JPG_HDCTBL(0), ARRAY_SIZE(hdctbl0)); + s5p_jpeg_set_htbl(regs, hdctbl0, S5P_JPG_HDCTBL(0), + ARRAY_SIZE(hdctbl0)); } -static inline void jpeg_set_hdctblg(void __iomem *regs) +static inline void s5p_jpeg_set_hdctblg(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hdctblg0, S5P_JPG_HDCTBLG(0), ARRAY_SIZE(hdctblg0)); + s5p_jpeg_set_htbl(regs, hdctblg0, S5P_JPG_HDCTBLG(0), + ARRAY_SIZE(hdctblg0)); } -static inline void jpeg_set_hactbl(void __iomem *regs) +static inline void s5p_jpeg_set_hactbl(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hactbl0, S5P_JPG_HACTBL(0), ARRAY_SIZE(hactbl0)); + s5p_jpeg_set_htbl(regs, hactbl0, S5P_JPG_HACTBL(0), + ARRAY_SIZE(hactbl0)); } -static inline void jpeg_set_hactblg(void __iomem *regs) +static inline void s5p_jpeg_set_hactblg(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hactblg0, S5P_JPG_HACTBLG(0), ARRAY_SIZE(hactblg0)); + s5p_jpeg_set_htbl(regs, hactblg0, S5P_JPG_HACTBLG(0), + ARRAY_SIZE(hactblg0)); } /* @@ -962,8 +970,8 @@ static void s5p_jpeg_device_run(void *priv) * JPEG IP allows storing 4 quantization tables * We fill table 0 for luma and table 1 for chroma */ - jpeg_set_qtbl_lum(jpeg->regs, ctx->compr_quality); - jpeg_set_qtbl_chr(jpeg->regs, ctx->compr_quality); + s5p_jpeg_set_qtbl_lum(jpeg->regs, ctx->compr_quality); + s5p_jpeg_set_qtbl_chr(jpeg->regs, ctx->compr_quality); /* use table 0 for Y */ jpeg_qtbl(jpeg->regs, 1, 0); /* use table 1 for Cb and Cr*/ @@ -1406,14 +1414,16 @@ static int s5p_jpeg_runtime_suspend(stru
Re: [PATCH 14/16] s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value
On 11/19/2013 03:46 PM, Hans Verkuil wrote: On 11/19/2013 03:27 PM, Jacek Anaszewski wrote: When output queue fourcc is set to any flavour of YUV, the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value as well as its in-driver cached counterpart have to be updated with the subsampling property of the format so as to be able to provide correct information to the user space and preclude setting an illegal subsampling mode for Exynos4x12 encoder. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |5 + 1 file changed, 5 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 319be0c..d4db612 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1038,6 +1038,7 @@ static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv, { struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); struct s5p_jpeg_fmt *fmt; + struct v4l2_control ctrl_subs; fmt = s5p_jpeg_find_format(ctx, f->fmt.pix.pixelformat, FMT_TYPE_OUTPUT); @@ -1048,6 +1049,10 @@ static int s5p_jpeg_try_fmt_vid_out(struct file *file, void *priv, return -EINVAL; } + ctrl_subs.id = V4L2_CID_JPEG_CHROMA_SUBSAMPLING; + ctrl_subs.value = fmt->subsampling; + v4l2_s_ctrl(priv, &ctx->ctrl_handler, &ctrl_subs); TRY_FMT should never have side-effects, so this isn't the correct way of implementing this. I am aware of it, but I couldn't have found more suitable place for implementing this. Below is the rationale standing behind such an implementation: - Exynos4x12 device doesn't generate an eoc interrupt if the subsampling property of an output queue format is lower than the target jpeg subsampling (e.g. V4L2_PIX_FMT_YUYV [4:2:2 subsampling] and JPEG 4:4:4) - It should be possible to inform the user space application that the subsampling it wants to set is not supported with the current output queue fourcc. - It is possible that after calling S_EXT_CTRLS the application will call S_FMT on output queue with different fourcc which will change the allowed scope of JPEG subsampling settings. Let's assume the following flow of ioctls: - S_FMT V4L2_PIX_FMT_YUYV (4:2:2) - S_EXT_CTRLS V4L2_JPEG_CHROMA_SUBSAMPLING_422 - S_FMT V4L2_PIX_FMT_YUV420 Now the JPEG subsampling set is illegal as 4:2:2 is lower than 4:2:0 (lower refers here to the lower number of luma samples assigned to the single chroma sample). It is evident now that the change of output queue fourcc entails change of the allowed scope of JPEG subsampling settings. The way I implemented it reflects this constraint precisely. We could go for adjusting the JPEG subsampling e.g. in the device_run callback but the user space application wouldn't know about it unless it called G_EXT_CTRLS ioctl after end of conversion. In view of the above it is clear that calling S_FMT in this case HAS side effect no matter whether we take it into account in the driver implementation or not. Nevertheless maybe there is some more elegant way of handling this problem I am not aware of. I am open to any interesting ideas. Regards, Jacek Anaszewski Also, don't use v4l2_s_ctrl, instead use v4l2_ctrl_s_ctrl. The v4l2_s_ctrl function is for core framework use only, not for use in drivers. Regards, Hans + return vidioc_try_fmt(f, fmt, ctx, FMT_TYPE_OUTPUT); } -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 00/16] Add support for Exynox4x12 to the s5p-jpeg driver
This is the second version of the series that adds support for the Exynos4x12 device to the s5p_jpeg driver along with accompanying fixes. It contains following improvements (Hans, Sylwester thanks for the review): - moved adjusting chroma subsampling control value from s_ctrl to try_ctrl callback and switched from using v4l2_s_ctrl to v4l2_ctrl_s_ctrl - avoided big switch statement in favour of lookup tables for adjusting capture queue fourcc during decoding phase - avoided unnecessary displacement of clk_get call in the probe function - renamed decoded_subsampling_to_v4l2 to s5p_jpeg_to_user_subsampling - added freeing ctrl_handler when v4l2_ctrl_handler_setup fails - calling s5p_jpeg_runtime_suspend and s5p_jpeg_runtime_resume only when pm_runtime_suspended returns false Thanks, Jacek Anaszewski Jacek Anaszewski (16): s5p-jpeg: Reorder quantization tables s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder s5p-jpeg: Fix erroneous condition while validating bytesperline value s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly s5p-jpeg: Fix clock resource management s5p-jpeg: Fix lack of spin_lock protection s5p-jpeg: Synchronize cached controls with V4L2 core s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec. s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header s5p-jpeg: Ensure correct capture format for Exynos4x12 s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value s5p-jpeg: Ensure setting correct value of the chroma subsampling control s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c| 1089 drivers/media/platform/s5p-jpeg/jpeg-core.h| 75 +- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c | 293 ++ drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h | 44 + .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 +- drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h| 215 +++- 8 files changed, 1614 insertions(+), 249 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 03/16] s5p-jpeg: Fix erroneous condition while validating bytesperline value
The aim of the condition is ensuring that the bytesperline value set by the user space application is proper for the given format and adjusting it if isn't. As the depth value of the format description entry is expressed in bits then the bytesperline value needs to be divided, not multiplied, by that value to get the number of bytes required to store single line of image samples. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 0f567c5..a1366f0 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -670,7 +670,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct s5p_jpeg_fmt *fmt, bpl = pix->width; /* planar */ if (fmt->colplanes == 1 && /* packed */ - (bpl << 3) * fmt->depth < pix->width) + (bpl << 3) / fmt->depth < pix->width) bpl = (pix->width * fmt->depth) >> 3; pix->bytesperline = bpl; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 02/16] s5p-jpeg: Fix output YUV 4:2:0 fourcc for decoder
Output samples during decoding phase for the YUV 4:2:0 format are arranged in the manner compatible with 2-planar NV12, not 3-planar YUV420 fourcc. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 2234944..0f567c5 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -58,7 +58,7 @@ static struct s5p_jpeg_fmt formats_enc[] = { static struct s5p_jpeg_fmt formats_dec[] = { { .name = "YUV 4:2:0 planar, YCbCr", - .fourcc = V4L2_PIX_FMT_YUV420, + .fourcc = V4L2_PIX_FMT_NV12, .depth = 12, .colplanes = 3, .h_align= 4, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 04/16] s5p-jpeg: Remove superfluous call to the jpeg_bound_align_image function
Aligning capture queue image dimensions while enqueuing output queue doesn't make a sense as the S_FMT ioctl might have not been called for the capture queue until that moment, whereas it is required to know capture format as the type of alignment heavily depends on it. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |7 --- 1 file changed, 7 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index a1366f0..a6ec8c6 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1089,13 +1089,6 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) q_data = &ctx->cap_q; q_data->w = tmp.w; q_data->h = tmp.h; - - jpeg_bound_align_image(&q_data->w, S5P_JPEG_MIN_WIDTH, - S5P_JPEG_MAX_WIDTH, q_data->fmt->h_align, - &q_data->h, S5P_JPEG_MIN_HEIGHT, - S5P_JPEG_MAX_HEIGHT, q_data->fmt->v_align - ); - q_data->size = q_data->w * q_data->h * q_data->fmt->depth >> 3; } v4l2_m2m_buf_queue(ctx->fh.m2m_ctx, vb); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 11/16] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
Make s5p_jpeg_parse_hdr function capable of parsing "YCbCr subsampling" field of a jpeg file header. Store the parsed value in the context. The information about source JPEG subsampling is required to make validation of destination format possible, which must be conducted for exynos4x12 device as the decoding process will not succeed if the destination format is set to YUV with subsampling lower than the one of the source JPEG image. With this knowledge the driver can adjust the destination format appropriately. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 --- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 02721a1..cb55f67 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -624,10 +624,11 @@ static void skip(struct s5p_jpeg_buffer *buf, long len) } static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, - unsigned long buffer, unsigned long size) + unsigned long buffer, unsigned long size, + struct s5p_jpeg_ctx *ctx) { int c, components, notfound; - unsigned int height, width, word; + unsigned int height, width, word, subsampling = 0; long length; struct s5p_jpeg_buffer jpeg_buffer; @@ -666,7 +667,15 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, break; notfound = 0; - skip(&jpeg_buffer, components * 3); + if (components == 1) { + subsampling = 0x33; + } else { + skip(&jpeg_buffer, 1); + subsampling = get_byte(&jpeg_buffer); + skip(&jpeg_buffer, 1); + } + + skip(&jpeg_buffer, components * 2); break; /* skip payload-less markers */ @@ -688,6 +697,24 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, result->w = width; result->h = height; result->size = components; + + switch (subsampling) { + case 0x11: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444; + break; + case 0x21: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422; + break; + case 0x22: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420; + break; + case 0x33: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; + break; + default: + return false; + } + return !notfound; } @@ -1435,7 +1462,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp, (unsigned long)vb2_plane_vaddr(vb, 0), min((unsigned long)ctx->out_q.size, -vb2_get_plane_payload(vb, 0))); +vb2_get_plane_payload(vb, 0)), ctx); if (!ctx->hdr_parsed) { vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); return; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 10/16] s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec.
Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c | 620 +++--- drivers/media/platform/s5p-jpeg/jpeg-core.h | 72 ++- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c | 293 ++ drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h | 44 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h | 215 +++- 6 files changed, 1152 insertions(+), 94 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos.h diff --git a/drivers/media/platform/s5p-jpeg/Makefile b/drivers/media/platform/s5p-jpeg/Makefile index faf6398..f981dff 100644 --- a/drivers/media/platform/s5p-jpeg/Makefile +++ b/drivers/media/platform/s5p-jpeg/Makefile @@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-exynos.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index b4d7445..02721a1 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1,9 +1,10 @@ /* linux/drivers/media/platform/s5p-jpeg/jpeg-core.c * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. * http://www.samsung.com * * Author: Andrzej Pietrasiewicz + * Author: Jacek Anaszewski * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -30,58 +31,212 @@ #include "jpeg-core.h" #include "jpeg-hw-s5p.h" +#include "jpeg-hw-exynos.h" +#include "jpeg-regs.h" -static struct s5p_jpeg_fmt formats_enc[] = { +static struct s5p_jpeg_fmt sjpeg_formats[] = { { .name = "JPEG JFIF", .fourcc = V4L2_PIX_FMT_JPEG, + .flags = SJPEG_FMT_FLAG_ENC_CAPTURE | + SJPEG_FMT_FLAG_DEC_OUTPUT | + SJPEG_FMT_FLAG_S5P | + SJPEG_FMT_FLAG_EXYNOS, + }, + { + .name = "YUV 4:2:2 packed, YCbYCr", + .fourcc = V4L2_PIX_FMT_YUYV, + .depth = 16, .colplanes = 1, - .types = MEM2MEM_CAPTURE, + .h_align= 4, + .v_align= 3, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_S5P | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, }, { .name = "YUV 4:2:2 packed, YCbYCr", .fourcc = V4L2_PIX_FMT_YUYV, .depth = 16, .colplanes = 1, - .types = MEM2MEM_OUTPUT, + .h_align= 1, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, + }, + { + .name = "YUV 4:2:2 packed, YCrYCb", + .fourcc = V4L2_PIX_FMT_YVYU, + .depth = 16, + .colplanes = 1, + .h_align= 1, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, }, { .name = "RGB565", .fourcc = V4L2_PIX_FMT_RGB565, .depth = 16, .colplanes = 1, - .types = MEM2MEM_OUTPUT, + .h_align= 0, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS | + SJPEG_FMT_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_444, + }, + { + .name = "RGB565", + .fourcc = V4L2_PIX_FMT_RGB565,
[PATCH v2 01/16] s5p-jpeg: Reorder quantization tables
Reorder quantization tables so that their elements are arranged in the manner reflecting compression quality level that is in accordance with V4L2 documentation, i.e. the larger value of the V4L2_CID_JPEG_COMPRESSION_QUALITY control the better image quality, and thus lower compression quality. The modification allows also to get rid of reverse logic in the s_ctrl callback while assigning user space value to the ctx->compr_quality variable. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 116 +-- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 47934db..2234944 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -84,15 +84,25 @@ static struct s5p_jpeg_fmt formats_dec[] = { #define NUM_FORMATS_DEC ARRAY_SIZE(formats_dec) static const unsigned char qtbl_luminance[4][64] = { - {/* level 1 - high quality */ -8, 6, 6, 8, 12, 14, 16, 17, -6, 6, 6, 8, 10, 13, 12, 15, -6, 6, 7, 8, 13, 14, 18, 24, -8, 8, 8, 14, 13, 19, 24, 35, - 12, 10, 13, 13, 20, 26, 34, 39, - 14, 13, 14, 19, 26, 34, 39, 39, - 16, 12, 18, 24, 34, 39, 39, 39, - 17, 15, 24, 35, 39, 39, 39, 39 + {/*level 0 - high compression quality */ + 20, 16, 25, 39, 50, 46, 62, 68, + 16, 18, 23, 38, 38, 53, 65, 68, + 25, 23, 31, 38, 53, 65, 68, 68, + 39, 38, 38, 53, 65, 68, 68, 68, + 50, 38, 53, 65, 68, 68, 68, 68, + 46, 53, 65, 68, 68, 68, 68, 68, + 62, 65, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68 + }, + {/* level 1 */ + 16, 11, 11, 16, 23, 27, 31, 30, + 11, 12, 12, 15, 20, 23, 23, 30, + 11, 12, 13, 16, 23, 26, 35, 47, + 16, 15, 16, 23, 26, 37, 47, 64, + 23, 20, 23, 26, 39, 51, 64, 64, + 27, 23, 26, 37, 51, 64, 64, 64, + 31, 23, 35, 47, 64, 64, 64, 64, + 30, 30, 47, 64, 64, 64, 64, 64 }, {/* level 2 */ 12, 8, 8, 12, 17, 21, 24, 23, @@ -104,38 +114,38 @@ static const unsigned char qtbl_luminance[4][64] = { 24, 18, 27, 36, 51, 59, 59, 59, 23, 23, 36, 53, 59, 59, 59, 59 }, - {/* level 3 */ - 16, 11, 11, 16, 23, 27, 31, 30, - 11, 12, 12, 15, 20, 23, 23, 30, - 11, 12, 13, 16, 23, 26, 35, 47, - 16, 15, 16, 23, 26, 37, 47, 64, - 23, 20, 23, 26, 39, 51, 64, 64, - 27, 23, 26, 37, 51, 64, 64, 64, - 31, 23, 35, 47, 64, 64, 64, 64, - 30, 30, 47, 64, 64, 64, 64, 64 - }, - {/*level 4 - low quality */ - 20, 16, 25, 39, 50, 46, 62, 68, - 16, 18, 23, 38, 38, 53, 65, 68, - 25, 23, 31, 38, 53, 65, 68, 68, - 39, 38, 38, 53, 65, 68, 68, 68, - 50, 38, 53, 65, 68, 68, 68, 68, - 46, 53, 65, 68, 68, 68, 68, 68, - 62, 65, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68 + {/* level 3 - low compression quality */ +8, 6, 6, 8, 12, 14, 16, 17, +6, 6, 6, 8, 10, 13, 12, 15, +6, 6, 7, 8, 13, 14, 18, 24, +8, 8, 8, 14, 13, 19, 24, 35, + 12, 10, 13, 13, 20, 26, 34, 39, + 14, 13, 14, 19, 26, 34, 39, 39, + 16, 12, 18, 24, 34, 39, 39, 39, + 17, 15, 24, 35, 39, 39, 39, 39 } }; static const unsigned char qtbl_chrominance[4][64] = { - {/* level 1 - high quality */ -9, 8, 9, 11, 14, 17, 19, 24, -8, 10, 9, 11, 14, 13, 17, 22, -9, 9, 13, 14, 13, 15, 23, 26, - 11, 11, 14, 14, 15, 20, 26, 33, - 14, 14, 13, 15, 20, 24, 33, 39, - 17, 13, 15, 20, 24, 32, 39, 39, - 19, 17, 23, 26, 33, 39, 39, 39, - 24, 22, 26, 33, 39, 39, 39, 39 + {/*level 0 - high compression quality */ + 21, 25, 32, 38, 54, 68, 68, 68, + 25, 28, 24, 38, 54, 68, 68, 68, + 32, 24, 32, 43, 66, 68, 68, 68, + 38, 38, 43, 53, 68, 68, 68, 68, + 54, 54, 66, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68, + 68, 68, 68, 68, 68, 68, 68, 68 + }, + {/* level 1 */ + 17, 15, 17, 21, 20, 26, 38, 48, + 15, 19, 18, 17, 20, 26, 35, 43, + 17, 18, 20, 22, 26, 30, 46, 53, + 21, 17, 22, 28, 30, 39, 53,
[PATCH v2 07/16] s5p-jpeg: Fix lack of spin_lock protection
s5p_jpeg_device_run and s5p_jpeg_runtime_resume callbacks should have spin_lock protection as they alter device registers. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 583fcdd..628fde8 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -930,7 +930,9 @@ static void s5p_jpeg_device_run(void *priv) struct s5p_jpeg_ctx *ctx = priv; struct s5p_jpeg *jpeg = ctx->jpeg; struct vb2_buffer *src_buf, *dst_buf; - unsigned long src_addr, dst_addr; + unsigned long src_addr, dst_addr, flags; + + spin_lock_irqsave(&ctx->jpeg->slock, flags); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst_buf = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); @@ -998,6 +1000,8 @@ static void s5p_jpeg_device_run(void *priv) } jpeg_start(jpeg->regs); + + spin_unlock_irqrestore(&ctx->jpeg->slock, flags); } static int s5p_jpeg_job_ready(void *priv) @@ -1418,12 +1422,15 @@ static int s5p_jpeg_runtime_suspend(struct device *dev) static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + unsigned long flags; int ret; ret = clk_prepare_enable(jpeg->clk); if (ret < 0) return ret; + spin_lock_irqsave(&jpeg->slock, flags); + /* * JPEG IP allows storing two Huffman tables for each component * We fill table 0 for each component @@ -1433,6 +1440,8 @@ static int s5p_jpeg_runtime_resume(struct device *dev) s5p_jpeg_set_hactbl(jpeg->regs); s5p_jpeg_set_hactblg(jpeg->regs); + spin_unlock_irqrestore(&jpeg->slock, flags); + return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 12/16] s5p-jpeg: Ensure correct capture format for Exynos4x12
Adjust capture format to the Exynos4x12 device limitations, according to the subsampling value parsed from the source JPEG image header. If the capture format was set to YUV with subsampling lower than the one of the source JPEG image the decoding process would not succeed. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 113 +++ 1 file changed, 113 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index cb55f67..76d8c12 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -358,6 +358,99 @@ static const unsigned char hactblg0[162] = { 0xf9, 0xfa }; +/* + * Fourcc downgrade schema lookup tables for 422 and 420 + * chroma subsampling - fourcc on each position maps on the + * fourcc from the table fourcc_to_dwngrd_schema_id which allows + * to get the most suitable fourcc counterpart for the given + * downgraded subsampling property. + */ +static const u32 subs422_fourcc_dwngrd_schema[] = { + V4L2_PIX_FMT_NV16, + V4L2_PIX_FMT_NV61, +}; + +static const u32 subs420_fourcc_dwngrd_schema[] = { + V4L2_PIX_FMT_NV12, + V4L2_PIX_FMT_NV21, + V4L2_PIX_FMT_NV12, + V4L2_PIX_FMT_NV21, + V4L2_PIX_FMT_NV12, + V4L2_PIX_FMT_NV21, + V4L2_PIX_FMT_GREY, + V4L2_PIX_FMT_GREY, + V4L2_PIX_FMT_GREY, + V4L2_PIX_FMT_GREY, +}; + +/* + * Lookup table for translation of a fourcc to the position + * of its downgraded counterpart in the *fourcc_dwngrd_schema + * tables. + */ +static const u32 fourcc_to_dwngrd_schema_id[] = { + V4L2_PIX_FMT_NV24, + V4L2_PIX_FMT_NV42, + V4L2_PIX_FMT_NV16, + V4L2_PIX_FMT_NV61, + V4L2_PIX_FMT_YUYV, + V4L2_PIX_FMT_YVYU, + V4L2_PIX_FMT_NV12, + V4L2_PIX_FMT_NV21, + V4L2_PIX_FMT_YUV420, + V4L2_PIX_FMT_GREY, +}; + +static int s5p_jpeg_get_dwngrd_sch_id_by_fourcc(u32 fourcc) +{ + int i; + for (i = 0; i < ARRAY_SIZE(fourcc_to_dwngrd_schema_id); ++i) { + if (fourcc_to_dwngrd_schema_id[i] == fourcc) + return i; + } + + return -EINVAL; +} + +static int s5p_jpeg_adjust_fourcc_to_subsampling( + enum v4l2_jpeg_chroma_subsampling subs, + u32 in_fourcc, + u32 *out_fourcc, + struct s5p_jpeg_ctx *ctx) +{ + int dwngrd_sch_id; + + if (ctx->subsampling != V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY) { + dwngrd_sch_id = + s5p_jpeg_get_dwngrd_sch_id_by_fourcc(in_fourcc); + if (dwngrd_sch_id < 0) + return -EINVAL; + } + + switch (ctx->subsampling) { + case V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY: + *out_fourcc = V4L2_PIX_FMT_GREY; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_420: + if (dwngrd_sch_id > + ARRAY_SIZE(subs420_fourcc_dwngrd_schema) - 1) + return -EINVAL; + *out_fourcc = subs420_fourcc_dwngrd_schema[dwngrd_sch_id]; + break; + case V4L2_JPEG_CHROMA_SUBSAMPLING_422: + if (dwngrd_sch_id > + ARRAY_SIZE(subs422_fourcc_dwngrd_schema) - 1) + return -EINVAL; + *out_fourcc = subs422_fourcc_dwngrd_schema[dwngrd_sch_id]; + break; + default: + *out_fourcc = V4L2_PIX_FMT_GREY; + break; + } + + return 0; +} + static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c) { return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler); @@ -941,7 +1034,9 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) { struct s5p_jpeg_ctx *ctx = fh_to_ctx(priv); + struct v4l2_pix_format *pix = &f->fmt.pix; struct s5p_jpeg_fmt *fmt; + int ret; fmt = s5p_jpeg_find_format(ctx, f->fmt.pix.pixelformat, FMT_TYPE_CAPTURE); @@ -952,6 +1047,24 @@ static int s5p_jpeg_try_fmt_vid_cap(struct file *file, void *priv, return -EINVAL; } + /* +* The exynos4x12 device requires resulting YUV image +* subsampling not to be lower than the input jpeg subsampling. +* If this requirement is not met then downgrade the requested +* capture format to the one with subsampling equal to the input jpeg. +*/ + if ((ctx->jpeg->variant->version != SJPEG_S5P) && + (ctx->mode == S5P_JPEG_DECODE) && + (fmt->flags & SJPE
[PATCH v2 09/16] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
Move function definitions from jpeg-hw.h to jpeg-hw-s5p.c and put function declarations in the jpeg-hw-s5p.h. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c|2 +- drivers/media/platform/s5p-jpeg/jpeg-core.h|5 ++ .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 +++ 5 files changed, 104 insertions(+), 50 deletions(-) rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (71%) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h diff --git a/drivers/media/platform/s5p-jpeg/Makefile b/drivers/media/platform/s5p-jpeg/Makefile index d18cb5e..faf6398 100644 --- a/drivers/media/platform/s5p-jpeg/Makefile +++ b/drivers/media/platform/s5p-jpeg/Makefile @@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index e907738..b4d7445 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -29,7 +29,7 @@ #include #include "jpeg-core.h" -#include "jpeg-hw.h" +#include "jpeg-hw-s5p.h" static struct s5p_jpeg_fmt formats_enc[] = { { diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.h b/drivers/media/platform/s5p-jpeg/jpeg-core.h index 4a4776b..7baadf3 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.h +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.h @@ -42,10 +42,15 @@ #define EOI0xd9 #define DHP0xde +#define S5P_JPEG_ENCODE0 +#define S5P_JPEG_DECODE1 + /* Flags that indicate a format can be used for capture/output */ #define MEM2MEM_CAPTURE(1 << 0) #define MEM2MEM_OUTPUT (1 << 1) + + /** * struct s5p_jpeg - JPEG IP abstraction * @lock: the mutex protecting this structure diff --git a/drivers/media/platform/s5p-jpeg/jpeg-hw.h b/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c similarity index 71% rename from drivers/media/platform/s5p-jpeg/jpeg-hw.h rename to drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c index b47e887..6a1164c 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-hw.h +++ b/drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.c @@ -9,27 +9,15 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#ifndef JPEG_HW_H_ -#define JPEG_HW_H_ #include #include -#include "jpeg-hw.h" +#include "jpeg-core.h" #include "jpeg-regs.h" +#include "jpeg-hw-s5p.h" -#define S5P_JPEG_MIN_WIDTH 32 -#define S5P_JPEG_MIN_HEIGHT32 -#define S5P_JPEG_MAX_WIDTH 8192 -#define S5P_JPEG_MAX_HEIGHT8192 -#define S5P_JPEG_ENCODE0 -#define S5P_JPEG_DECODE1 -#define S5P_JPEG_RAW_IN_5650 -#define S5P_JPEG_RAW_IN_4221 -#define S5P_JPEG_RAW_OUT_422 0 -#define S5P_JPEG_RAW_OUT_420 1 - -static inline void jpeg_reset(void __iomem *regs) +void jpeg_reset(void __iomem *regs) { unsigned long reg; @@ -42,12 +30,12 @@ static inline void jpeg_reset(void __iomem *regs) } } -static inline void jpeg_poweron(void __iomem *regs) +void jpeg_poweron(void __iomem *regs) { writel(S5P_POWER_ON, regs + S5P_JPGCLKCON); } -static inline void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode) +void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode) { unsigned long reg, m; @@ -63,7 +51,7 @@ static inline void jpeg_input_raw_mode(void __iomem *regs, unsigned long mode) writel(reg, regs + S5P_JPGCMOD); } -static inline void jpeg_input_raw_y16(void __iomem *regs, bool y16) +void jpeg_input_raw_y16(void __iomem *regs, bool y16) { unsigned long reg; @@ -75,7 +63,7 @@ static inline void jpeg_input_raw_y16(void __iomem *regs, bool y16) writel(reg, regs + S5P_JPGCMOD); } -static inline void jpeg_proc_mode(void __iomem *regs, unsigned long mode) +void jpeg_proc_mode(void __iomem *regs, unsigned long mode) { unsigned long reg, m; @@ -90,7 +78,7 @@ static inline void jpeg_proc_mode(void __iomem *regs, unsigned long mode) writel(reg, regs + S5P_JPGMOD); } -static inline void jpeg_subsampling_mode(void __iomem *regs, unsigned int mode) +void jpeg_subsampling_mode(void __iomem *regs, unsigned int mode) { unsigned long reg, m; @@ -105,12 +93,12 @@ static inline void jpeg_subsampling_mode(void __iomem *regs, unsigned int mode) writel(reg, regs + S5
[PATCH v2 13/16] s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder
Exynos4x12 supports wider scope of subsampling modes than S5PC210. Adjust corresponding mask accordingly. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 76d8c12..e85ac6a 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1246,7 +1246,8 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx) v4l2_ctrl_new_std(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops, V4L2_CID_JPEG_RESTART_INTERVAL, 0, 3, 0x, 0); - mask = ~0x06; /* 422, 420 */ + if (ctx->jpeg->variant->version == SJPEG_S5P) + mask = ~0x06; /* 422, 420 */ } ctrl = v4l2_ctrl_new_std_menu(&ctx->ctrl_handler, &s5p_jpeg_ctrl_ops, -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 05/16] s5p-jpeg: Rename functions specific to the S5PC210 SoC accordingly
Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 58 --- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index a6ec8c6..32033e7 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -213,8 +213,9 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh) return container_of(fh, struct s5p_jpeg_ctx, fh); } -static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, - unsigned long tab, int len) +static inline void s5p_jpeg_set_qtbl(void __iomem *regs, +const unsigned char *qtbl, +unsigned long tab, int len) { int i; @@ -222,22 +223,25 @@ static inline void jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, writel((unsigned int)qtbl[i], regs + tab + (i * 0x04)); } -static inline void jpeg_set_qtbl_lum(void __iomem *regs, int quality) +static inline void s5p_jpeg_set_qtbl_lum(void __iomem *regs, int quality) { /* this driver fills quantisation table 0 with data for luma */ - jpeg_set_qtbl(regs, qtbl_luminance[quality], S5P_JPG_QTBL_CONTENT(0), - ARRAY_SIZE(qtbl_luminance[quality])); + s5p_jpeg_set_qtbl(regs, qtbl_luminance[quality], + S5P_JPG_QTBL_CONTENT(0), + ARRAY_SIZE(qtbl_luminance[quality])); } -static inline void jpeg_set_qtbl_chr(void __iomem *regs, int quality) +static inline void s5p_jpeg_set_qtbl_chr(void __iomem *regs, int quality) { /* this driver fills quantisation table 1 with data for chroma */ - jpeg_set_qtbl(regs, qtbl_chrominance[quality], S5P_JPG_QTBL_CONTENT(1), - ARRAY_SIZE(qtbl_chrominance[quality])); + s5p_jpeg_set_qtbl(regs, qtbl_chrominance[quality], + S5P_JPG_QTBL_CONTENT(1), + ARRAY_SIZE(qtbl_chrominance[quality])); } -static inline void jpeg_set_htbl(void __iomem *regs, const unsigned char *htbl, - unsigned long tab, int len) +static inline void s5p_jpeg_set_htbl(void __iomem *regs, +const unsigned char *htbl, +unsigned long tab, int len) { int i; @@ -245,28 +249,32 @@ static inline void jpeg_set_htbl(void __iomem *regs, const unsigned char *htbl, writel((unsigned int)htbl[i], regs + tab + (i * 0x04)); } -static inline void jpeg_set_hdctbl(void __iomem *regs) +static inline void s5p_jpeg_set_hdctbl(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hdctbl0, S5P_JPG_HDCTBL(0), ARRAY_SIZE(hdctbl0)); + s5p_jpeg_set_htbl(regs, hdctbl0, S5P_JPG_HDCTBL(0), + ARRAY_SIZE(hdctbl0)); } -static inline void jpeg_set_hdctblg(void __iomem *regs) +static inline void s5p_jpeg_set_hdctblg(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hdctblg0, S5P_JPG_HDCTBLG(0), ARRAY_SIZE(hdctblg0)); + s5p_jpeg_set_htbl(regs, hdctblg0, S5P_JPG_HDCTBLG(0), + ARRAY_SIZE(hdctblg0)); } -static inline void jpeg_set_hactbl(void __iomem *regs) +static inline void s5p_jpeg_set_hactbl(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hactbl0, S5P_JPG_HACTBL(0), ARRAY_SIZE(hactbl0)); + s5p_jpeg_set_htbl(regs, hactbl0, S5P_JPG_HACTBL(0), + ARRAY_SIZE(hactbl0)); } -static inline void jpeg_set_hactblg(void __iomem *regs) +static inline void s5p_jpeg_set_hactblg(void __iomem *regs) { /* this driver fills table 0 for this component */ - jpeg_set_htbl(regs, hactblg0, S5P_JPG_HACTBLG(0), ARRAY_SIZE(hactblg0)); + s5p_jpeg_set_htbl(regs, hactblg0, S5P_JPG_HACTBLG(0), + ARRAY_SIZE(hactblg0)); } /* @@ -962,8 +970,8 @@ static void s5p_jpeg_device_run(void *priv) * JPEG IP allows storing 4 quantization tables * We fill table 0 for luma and table 1 for chroma */ - jpeg_set_qtbl_lum(jpeg->regs, ctx->compr_quality); - jpeg_set_qtbl_chr(jpeg->regs, ctx->compr_quality); + s5p_jpeg_set_qtbl_lum(jpeg->regs, ctx->compr_quality); + s5p_jpeg_set_qtbl_chr(jpeg->regs, ctx->compr_quality); /* use table 0 for Y */ jpeg_qtbl(jpeg->regs, 1, 0); /* use table 1 for Cb and Cr*/ @@ -1406,14 +1414,16 @@ static int s5p_jpeg_runtime_suspend(stru
[PATCH v2 14/16] s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value
When output queue fourcc is set to any flavour of YUV, the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value as well as its in-driver cached counterpart have to be updated with the subsampling property of the format so as to be able to provide correct information to the user space and preclude setting an illegal subsampling mode for Exynos4x12 encoder. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c |8 1 file changed, 8 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index e85ac6a..163ee8d 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1091,6 +1091,7 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) struct vb2_queue *vq; struct s5p_jpeg_q_data *q_data = NULL; struct v4l2_pix_format *pix = &f->fmt.pix; + struct v4l2_ctrl *ctrl_subs; unsigned int f_type; vq = v4l2_m2m_get_vq(ct->fh.m2m_ctx, f->type); @@ -1116,6 +1117,13 @@ static int s5p_jpeg_s_fmt(struct s5p_jpeg_ctx *ct, struct v4l2_format *f) else q_data->size = pix->sizeimage; + if (f_type == FMT_TYPE_OUTPUT) { + ctrl_subs = v4l2_ctrl_find(&ct->ctrl_handler, + V4L2_CID_JPEG_CHROMA_SUBSAMPLING); + if (ctrl_subs) + v4l2_ctrl_s_ctrl(ctrl_subs, q_data->fmt->subsampling); + } + return 0; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 06/16] s5p-jpeg: Fix clock resource management
Standard suspend/resume path is called after runtime resume of the given device, so suspend/resume callbacks must do all clock management done also by runtime pm to allow for proper power domain shutdown. Moreover, JPEG clock is enabled from probe function but is is not necessary. This patch also moves control of jpeg clock to runtime_pm callbacks. Signed-off-by: Marek Szyprowski Signed-off-by: Seung-Woo Kim Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 +++ 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 32033e7..583fcdd 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1272,7 +1272,6 @@ static int s5p_jpeg_probe(struct platform_device *pdev) return ret; } dev_dbg(&pdev->dev, "clock source %p\n", jpeg->clk); - clk_prepare_enable(jpeg->clk); /* v4l2 device */ ret = v4l2_device_register(&pdev->dev, &jpeg->v4l2_dev); @@ -1380,7 +1379,6 @@ device_register_rollback: v4l2_device_unregister(&jpeg->v4l2_dev); clk_get_rollback: - clk_disable_unprepare(jpeg->clk); clk_put(jpeg->clk); return ret; @@ -1400,7 +1398,9 @@ static int s5p_jpeg_remove(struct platform_device *pdev) v4l2_m2m_release(jpeg->m2m_dev); v4l2_device_unregister(&jpeg->v4l2_dev); - clk_disable_unprepare(jpeg->clk); + if (!pm_runtime_status_suspended(&pdev->dev)) + clk_disable_unprepare(jpeg->clk); + clk_put(jpeg->clk); return 0; @@ -1408,12 +1408,21 @@ static int s5p_jpeg_remove(struct platform_device *pdev) static int s5p_jpeg_runtime_suspend(struct device *dev) { + struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + + clk_disable_unprepare(jpeg->clk); + return 0; } static int s5p_jpeg_runtime_resume(struct device *dev) { struct s5p_jpeg *jpeg = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(jpeg->clk); + if (ret < 0) + return ret; /* * JPEG IP allows storing two Huffman tables for each component @@ -1427,9 +1436,25 @@ static int s5p_jpeg_runtime_resume(struct device *dev) return 0; } +static int s5p_jpeg_suspend(struct device *dev) +{ + if (pm_runtime_suspended(dev)) + return 0; + + return s5p_jpeg_runtime_suspend(dev); +} + +static int s5p_jpeg_resume(struct device *dev) +{ + if (pm_runtime_suspended(dev)) + return 0; + + return s5p_jpeg_runtime_resume(dev); +} + static const struct dev_pm_ops s5p_jpeg_pm_ops = { - .runtime_suspend = s5p_jpeg_runtime_suspend, - .runtime_resume = s5p_jpeg_runtime_resume, + SET_SYSTEM_SLEEP_PM_OPS(s5p_jpeg_suspend, s5p_jpeg_resume) + SET_RUNTIME_PM_OPS(s5p_jpeg_runtime_suspend, s5p_jpeg_runtime_resume, NULL) }; #ifdef CONFIG_OF -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 08/16] s5p-jpeg: Synchronize cached controls with V4L2 core
This patch adds proper initialization of the in-driver cached state of JPEG controls with V4L2 core. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 628fde8..e907738 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -865,6 +865,7 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx) { unsigned int mask = ~0x27; /* 444, 422, 420, GRAY */ struct v4l2_ctrl *ctrl; + int ret; v4l2_ctrl_handler_init(&ctx->ctrl_handler, 3); @@ -884,13 +885,24 @@ static int s5p_jpeg_controls_create(struct s5p_jpeg_ctx *ctx) V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY, mask, V4L2_JPEG_CHROMA_SUBSAMPLING_422); - if (ctx->ctrl_handler.error) - return ctx->ctrl_handler.error; + if (ctx->ctrl_handler.error) { + ret = ctx->ctrl_handler.error; + goto error_free; + } if (ctx->mode == S5P_JPEG_DECODE) ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_READ_ONLY; - return 0; + + ret = v4l2_ctrl_handler_setup(&ctx->ctrl_handler); + if (ret < 0) + goto error_free; + + return ret; + +error_free: + v4l2_ctrl_handler_free(&ctx->ctrl_handler); + return ret; } static const struct v4l2_ioctl_ops s5p_jpeg_ioctl_ops = { -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 15/16] s5p-jpeg: Ensure setting correct value of the chroma subsampling control
Exynos4x12 has limitations regarding setting chroma subsampling of an output JPEG image. It cannot be lower than the subsampling of the raw source image. Also in case of V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY option the source image fourcc has to be V4L2_PIX_FMT_GREY. This patch implements try_ctrl callback containing mechanism that prevents setting invalid value of the V4L2_CID_JPEG_CHROMA_SUBSAMPLING control. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 +++ 1 file changed, 35 insertions(+) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 163ee8d..ad259af 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1210,6 +1210,40 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl) return 0; } +static int s5p_jpeg_try_ctrl(struct v4l2_ctrl *ctrl) +{ + struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl); + unsigned long flags; + int ret = 0; + + spin_lock_irqsave(&ctx->jpeg->slock, flags); + + if (ctrl->id == V4L2_CID_JPEG_CHROMA_SUBSAMPLING) { + if (ctx->jpeg->variant->version == SJPEG_S5P) + goto error_free; + /* +* The exynos4x12 device requires input raw image fourcc +* to be V4L2_PIX_FMT_GREY if gray jpeg format +* is to be set. +*/ + if (ctx->out_q.fmt->fourcc != V4L2_PIX_FMT_GREY && + ctrl->val == V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY) { + ret = -EINVAL; + goto error_free; + } + /* +* The exynos4x12 device requires resulting jpeg subsampling +* not to be lower than the input raw image subsampling. +*/ + if (ctx->out_q.fmt->subsampling > ctrl->val) + ctrl->val = ctx->out_q.fmt->subsampling; + } + +error_free: + spin_unlock_irqrestore(&ctx->jpeg->slock, flags); + return ret; +} + static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl) { struct s5p_jpeg_ctx *ctx = ctrl_to_ctx(ctrl); @@ -1235,6 +1269,7 @@ static int s5p_jpeg_s_ctrl(struct v4l2_ctrl *ctrl) static const struct v4l2_ctrl_ops s5p_jpeg_ctrl_ops = { .g_volatile_ctrl= s5p_jpeg_g_volatile_ctrl, + .try_ctrl = s5p_jpeg_try_ctrl, .s_ctrl = s5p_jpeg_s_ctrl, }; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 16/16] s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs
Whereas S5PC210 device produces decoded JPEG subsampling values that map on V4L2_JPEG_CHROMA_SUBSAMPLNG values, the Exynos4x12 device doesn't. This patch adds helper function s5p_jpeg_to_user_subsampling, which performs suitable translation. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 32 ++- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index ad259af..5eb1ee9 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -451,6 +451,13 @@ static int s5p_jpeg_adjust_fourcc_to_subsampling( return 0; } +static int exynos4x12_decoded_subsampling[] = { + V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY, + V4L2_JPEG_CHROMA_SUBSAMPLING_444, + V4L2_JPEG_CHROMA_SUBSAMPLING_422, + V4L2_JPEG_CHROMA_SUBSAMPLING_420, +}; + static inline struct s5p_jpeg_ctx *ctrl_to_ctx(struct v4l2_ctrl *c) { return container_of(c->handler, struct s5p_jpeg_ctx, ctrl_handler); @@ -461,6 +468,24 @@ static inline struct s5p_jpeg_ctx *fh_to_ctx(struct v4l2_fh *fh) return container_of(fh, struct s5p_jpeg_ctx, fh); } +static int s5p_jpeg_to_user_subsampling(struct s5p_jpeg_ctx *ctx) +{ + WARN_ON(ctx->subsampling > 3); + + if (ctx->jpeg->variant->version == SJPEG_S5P) { + if (ctx->subsampling > 2) + return V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; + else + return ctx->subsampling; + } else { + if (ctx->subsampling > 2) + return V4L2_JPEG_CHROMA_SUBSAMPLING_420; + else + return + exynos4x12_decoded_subsampling[ctx->subsampling]; + } +} + static inline void s5p_jpeg_set_qtbl(void __iomem *regs, const unsigned char *qtbl, unsigned long tab, int len) @@ -1197,12 +1222,7 @@ static int s5p_jpeg_g_volatile_ctrl(struct v4l2_ctrl *ctrl) switch (ctrl->id) { case V4L2_CID_JPEG_CHROMA_SUBSAMPLING: spin_lock_irqsave(&jpeg->slock, flags); - - WARN_ON(ctx->subsampling > S5P_SUBSAMPLING_MODE_GRAY); - if (ctx->subsampling > 2) - ctrl->val = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; - else - ctrl->val = ctx->subsampling; + ctrl->val = s5p_jpeg_to_user_subsampling(ctx); spin_unlock_irqrestore(&jpeg->slock, flags); break; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 2/8] s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec.
Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c | 621 ++--- drivers/media/platform/s5p-jpeg/jpeg-core.h | 64 ++- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 279 + drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.h | 42 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h | 209 ++- 6 files changed, 1123 insertions(+), 94 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.h diff --git a/drivers/media/platform/s5p-jpeg/Makefile b/drivers/media/platform/s5p-jpeg/Makefile index faf6398..a1a9169 100644 --- a/drivers/media/platform/s5p-jpeg/Makefile +++ b/drivers/media/platform/s5p-jpeg/Makefile @@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-exynos4.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index bfacaec..242e8b8 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -1,9 +1,10 @@ /* linux/drivers/media/platform/s5p-jpeg/jpeg-core.c * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. + * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. * http://www.samsung.com * * Author: Andrzej Pietrasiewicz + * Author: Jacek Anaszewski * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -30,58 +31,212 @@ #include "jpeg-core.h" #include "jpeg-hw-s5p.h" +#include "jpeg-hw-exynos4.h" +#include "jpeg-regs.h" -static struct s5p_jpeg_fmt formats_enc[] = { +static struct s5p_jpeg_fmt sjpeg_formats[] = { { .name = "JPEG JFIF", .fourcc = V4L2_PIX_FMT_JPEG, + .flags = SJPEG_FMT_FLAG_ENC_CAPTURE | + SJPEG_FMT_FLAG_DEC_OUTPUT | + SJPEG_FMT_FLAG_S5P | + SJPEG_FMT_FLAG_EXYNOS4, + }, + { + .name = "YUV 4:2:2 packed, YCbYCr", + .fourcc = V4L2_PIX_FMT_YUYV, + .depth = 16, .colplanes = 1, - .types = MEM2MEM_CAPTURE, + .h_align= 4, + .v_align= 3, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_S5P | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, }, { .name = "YUV 4:2:2 packed, YCbYCr", .fourcc = V4L2_PIX_FMT_YUYV, .depth = 16, .colplanes = 1, - .types = MEM2MEM_OUTPUT, + .h_align= 1, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS4 | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, + }, + { + .name = "YUV 4:2:2 packed, YCrYCb", + .fourcc = V4L2_PIX_FMT_YVYU, + .depth = 16, + .colplanes = 1, + .h_align= 1, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS4 | + SJPEG_FMT_NON_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_422, }, { .name = "RGB565", .fourcc = V4L2_PIX_FMT_RGB565, .depth = 16, .colplanes = 1, - .types = MEM2MEM_OUTPUT, + .h_align= 0, + .v_align= 0, + .flags = SJPEG_FMT_FLAG_ENC_OUTPUT | + SJPEG_FMT_FLAG_DEC_CAPTURE | + SJPEG_FMT_FLAG_EXYNOS4 | + SJPEG_FMT_RGB, + .subsampling= V4L2_JPEG_CHROMA_SUBSAMPLING_444, + }, + { + .name = "RGB565", + .fourcc
[PATCH v3 0/8] Add support for Exynos4x12 device to the s5p-jpeg driver
This is the third version of the series that adds support for the Exynos4x12 device to the s5p_jpeg driver. It includes following changes (Mauro - thanks for the review): - renamed all occurrences of "exynos" to more precise "exynos4" - added "s5p" and "exynos4" prefixes to the HW API functions Thanks, Jacek Anaszewski Jacek Anaszewski (8): s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c s5p-jpeg: Add hardware API for the exynos4x12 JPEG codec. s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header s5p-jpeg: Ensure correct capture format for Exynos4x12 s5p-jpeg: Allow for wider JPEG subsampling scope for Exynos4x12 encoder s5p-jpeg: Synchronize V4L2_CID_JPEG_CHROMA_SUBSAMPLING control value s5p-jpeg: Ensure setting correct value of the chroma subsampling control s5p-jpeg: Adjust g_volatile_ctrl callback to Exynos4x12 needs drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c| 946 +--- drivers/media/platform/s5p-jpeg/jpeg-core.h| 67 +- drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c | 279 ++ drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.h | 42 + .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 +- drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 ++ drivers/media/platform/s5p-jpeg/jpeg-regs.h| 209 - 8 files changed, 1490 insertions(+), 200 deletions(-) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.c create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-exynos4.h rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (70%) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 1/8] s5p-jpeg: Split jpeg-hw.h to jpeg-hw-s5p.c and jpeg-hw-s5p.c
Move function definitions from jpeg-hw.h to jpeg-hw-s5p.c, add "s5p" prefix and put function declarations in the jpeg-hw-s5p.h. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/Makefile |2 +- drivers/media/platform/s5p-jpeg/jpeg-core.c| 99 ++-- drivers/media/platform/s5p-jpeg/jpeg-core.h|5 + .../platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} | 82 +++- drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h | 63 + 5 files changed, 154 insertions(+), 97 deletions(-) rename drivers/media/platform/s5p-jpeg/{jpeg-hw.h => jpeg-hw-s5p.c} (70%) create mode 100644 drivers/media/platform/s5p-jpeg/jpeg-hw-s5p.h diff --git a/drivers/media/platform/s5p-jpeg/Makefile b/drivers/media/platform/s5p-jpeg/Makefile index d18cb5e..faf6398 100644 --- a/drivers/media/platform/s5p-jpeg/Makefile +++ b/drivers/media/platform/s5p-jpeg/Makefile @@ -1,2 +1,2 @@ -s5p-jpeg-objs := jpeg-core.o +s5p-jpeg-objs := jpeg-core.o jpeg-hw-s5p.o obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index e907738..bfacaec 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -29,7 +29,7 @@ #include #include "jpeg-core.h" -#include "jpeg-hw.h" +#include "jpeg-hw-s5p.h" static struct s5p_jpeg_fmt formats_enc[] = { { @@ -951,34 +951,36 @@ static void s5p_jpeg_device_run(void *priv) src_addr = vb2_dma_contig_plane_dma_addr(src_buf, 0); dst_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0); - jpeg_reset(jpeg->regs); - jpeg_poweron(jpeg->regs); - jpeg_proc_mode(jpeg->regs, ctx->mode); + s5p_jpeg_reset(jpeg->regs); + s5p_jpeg_poweron(jpeg->regs); + s5p_jpeg_proc_mode(jpeg->regs, ctx->mode); if (ctx->mode == S5P_JPEG_ENCODE) { if (ctx->out_q.fmt->fourcc == V4L2_PIX_FMT_RGB565) - jpeg_input_raw_mode(jpeg->regs, S5P_JPEG_RAW_IN_565); + s5p_jpeg_input_raw_mode(jpeg->regs, + S5P_JPEG_RAW_IN_565); else - jpeg_input_raw_mode(jpeg->regs, S5P_JPEG_RAW_IN_422); - jpeg_subsampling_mode(jpeg->regs, ctx->subsampling); - jpeg_dri(jpeg->regs, ctx->restart_interval); - jpeg_x(jpeg->regs, ctx->out_q.w); - jpeg_y(jpeg->regs, ctx->out_q.h); - jpeg_imgadr(jpeg->regs, src_addr); - jpeg_jpgadr(jpeg->regs, dst_addr); + s5p_jpeg_input_raw_mode(jpeg->regs, + S5P_JPEG_RAW_IN_422); + s5p_jpeg_subsampling_mode(jpeg->regs, ctx->subsampling); + s5p_jpeg_dri(jpeg->regs, ctx->restart_interval); + s5p_jpeg_x(jpeg->regs, ctx->out_q.w); + s5p_jpeg_y(jpeg->regs, ctx->out_q.h); + s5p_jpeg_imgadr(jpeg->regs, src_addr); + s5p_jpeg_jpgadr(jpeg->regs, dst_addr); /* ultimately comes from sizeimage from userspace */ - jpeg_enc_stream_int(jpeg->regs, ctx->cap_q.size); + s5p_jpeg_enc_stream_int(jpeg->regs, ctx->cap_q.size); /* JPEG RGB to YCbCr conversion matrix */ - jpeg_coef(jpeg->regs, 1, 1, S5P_JPEG_COEF11); - jpeg_coef(jpeg->regs, 1, 2, S5P_JPEG_COEF12); - jpeg_coef(jpeg->regs, 1, 3, S5P_JPEG_COEF13); - jpeg_coef(jpeg->regs, 2, 1, S5P_JPEG_COEF21); - jpeg_coef(jpeg->regs, 2, 2, S5P_JPEG_COEF22); - jpeg_coef(jpeg->regs, 2, 3, S5P_JPEG_COEF23); - jpeg_coef(jpeg->regs, 3, 1, S5P_JPEG_COEF31); - jpeg_coef(jpeg->regs, 3, 2, S5P_JPEG_COEF32); - jpeg_coef(jpeg->regs, 3, 3, S5P_JPEG_COEF33); + s5p_jpeg_coef(jpeg->regs, 1, 1, S5P_JPEG_COEF11); + s5p_jpeg_coef(jpeg->regs, 1, 2, S5P_JPEG_COEF12); + s5p_jpeg_coef(jpeg->regs, 1, 3, S5P_JPEG_COEF13); + s5p_jpeg_coef(jpeg->regs, 2, 1, S5P_JPEG_COEF21); + s5p_jpeg_coef(jpeg->regs, 2, 2, S5P_JPEG_COEF22); + s5p_jpeg_coef(jpeg->regs, 2, 3, S5P_JPEG_COEF23); + s5p_jpeg_coef(jpeg->regs, 3, 1, S5P_JPEG_COEF31); + s5p_jpeg_coef(jpeg->regs, 3, 2, S5P_JPEG_COEF32); + s5p_jpeg_coef(jpeg->regs, 3, 3, S5P_JPEG_COEF33); /* * JPEG IP allows storing 4 quantization tables @@ -987,31 +989,31 @@ static void s5p_jpeg_device_run(void *priv)
[PATCH v3 3/8] s5p-jpeg: Retrieve "YCbCr subsampling" field from the jpeg header
Make s5p_jpeg_parse_hdr function capable of parsing "YCbCr subsampling" field of a jpeg file header. Store the parsed value in the context. The information about source JPEG subsampling is required to make validation of destination format possible, which must be conducted for exynos4x12 device as the decoding process will not succeed if the destination format is set to YUV with subsampling lower than the one of the source JPEG image. With this knowledge the driver can adjust the destination format appropriately. Signed-off-by: Jacek Anaszewski Signed-off-by: Kyungmin Park --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 35 --- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 242e8b8..ffae566 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -624,10 +624,11 @@ static void skip(struct s5p_jpeg_buffer *buf, long len) } static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, - unsigned long buffer, unsigned long size) + unsigned long buffer, unsigned long size, + struct s5p_jpeg_ctx *ctx) { int c, components, notfound; - unsigned int height, width, word; + unsigned int height, width, word, subsampling = 0; long length; struct s5p_jpeg_buffer jpeg_buffer; @@ -666,7 +667,15 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, break; notfound = 0; - skip(&jpeg_buffer, components * 3); + if (components == 1) { + subsampling = 0x33; + } else { + skip(&jpeg_buffer, 1); + subsampling = get_byte(&jpeg_buffer); + skip(&jpeg_buffer, 1); + } + + skip(&jpeg_buffer, components * 2); break; /* skip payload-less markers */ @@ -688,6 +697,24 @@ static bool s5p_jpeg_parse_hdr(struct s5p_jpeg_q_data *result, result->w = width; result->h = height; result->size = components; + + switch (subsampling) { + case 0x11: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_444; + break; + case 0x21: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_422; + break; + case 0x22: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_420; + break; + case 0x33: + ctx->subsampling = V4L2_JPEG_CHROMA_SUBSAMPLING_GRAY; + break; + default: + return false; + } + return !notfound; } @@ -1438,7 +1465,7 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) ctx->hdr_parsed = s5p_jpeg_parse_hdr(&tmp, (unsigned long)vb2_plane_vaddr(vb, 0), min((unsigned long)ctx->out_q.size, -vb2_get_plane_payload(vb, 0))); +vb2_get_plane_payload(vb, 0)), ctx); if (!ctx->hdr_parsed) { vb2_buffer_done(vb, VB2_BUF_STATE_ERROR); return; -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html