Skip to content

Commit

Permalink
Merge tag 'media/v4.8-7' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/mchehab/linux-media

Pull media fixes from Mauro Carvalho Chehab:

 - several fixes for new drivers added for Kernel 4.8 addition (cec
   core, pulse8 cec driver and Mediatek vcodec)

 - a regression fix for cx23885 and saa7134 drivers

 - an important fix for rcar-fcp, making rcar_fcp_enable() return 0 on
   success

* tag 'media/v4.8-7' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (25 commits)
  [media] cx23885/saa7134: assign q->dev to the PCI device
  [media] rcar-fcp: Make sure rcar_fcp_enable() returns 0 on success
  [media] cec: fix ioctl return code when not registered
  [media] cec: don't Feature Abort broadcast msgs when unregistered
  [media] vcodec:mediatek: Refine VP8 encoder driver
  [media] vcodec:mediatek: Refine H264 encoder driver
  [media] vcodec:mediatek: change H264 profile default to profile high
  [media] vcodec:mediatek: Add timestamp and timecode copy for V4L2 Encoder
  [media] vcodec:mediatek: Fix visible_height larger than coded_height issue in s_fmt_out
  [media] vcodec:mediatek: Fix fops_vcodec_release flow for V4L2 Encoder
  [media] vcodec:mediatek:code refine for v4l2 Encoder driver
  [media] cec-funcs.h: add missing vendor-specific messages
  [media] cec-edid: check for IEEE identifier
  [media] pulse8-cec: fix error handling
  [media] pulse8-cec: set correct Signal Free Time
  [media] mtk-vcodec: add HAS_DMA dependency
  [media] cec: ignore messages when log_addr_mask == 0
  [media] cec: add item to TODO
  [media] cec: set unclaimed addresses to CEC_LOG_ADDR_INVALID
  [media] cec: add CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK flag
  ...
  • Loading branch information
torvalds committed Sep 22, 2016
2 parents f887c21 + d8feef9 commit b1f2beb
Show file tree
Hide file tree
Showing 22 changed files with 212 additions and 78 deletions.
21 changes: 20 additions & 1 deletion Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ logical address types are already defined will return with error ``EBUSY``.

- ``flags``

- Flags. No flags are defined yet, so set this to 0.
- Flags. See :ref:`cec-log-addrs-flags` for a list of available flags.

- .. row 7

Expand Down Expand Up @@ -201,6 +201,25 @@ logical address types are already defined will return with error ``EBUSY``.
give the CEC framework more information about the device type, even
though the framework won't use it directly in the CEC message.

.. _cec-log-addrs-flags:

.. flat-table:: Flags for struct cec_log_addrs
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4


- .. _`CEC-LOG-ADDRS-FL-ALLOW-UNREG-FALLBACK`:

- ``CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK``

- 1

- By default if no logical address of the requested type can be claimed, then
it will go back to the unconfigured state. If this flag is set, then it will
fallback to the Unregistered logical address. Note that if the Unregistered
logical address was explicitly requested, then this flag has no effect.

.. _cec-versions:

.. flat-table:: CEC Versions
Expand Down
8 changes: 6 additions & 2 deletions Documentation/media/uapi/cec/cec-ioc-dqevent.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,19 @@ it is guaranteed that the state did change in between the two events.

- ``phys_addr``

- The current physical address.
- The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
valid physical address is set.

- .. row 2

- __u16

- ``log_addr_mask``

- The current set of claimed logical addresses.
- The current set of claimed logical addresses. This is 0 if no logical
addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``.
If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device
has the unregistered logical address. In that case all other bits are 0.



Expand Down
5 changes: 4 additions & 1 deletion drivers/media/cec-edid.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ static unsigned int cec_get_edid_spa_location(const u8 *edid, unsigned int size)
u8 tag = edid[i] >> 5;
u8 len = edid[i] & 0x1f;

if (tag == 3 && len >= 5 && i + len <= end)
if (tag == 3 && len >= 5 && i + len <= end &&
edid[i + 1] == 0x03 &&
edid[i + 2] == 0x0c &&
edid[i + 3] == 0x00)
return i + 4;
i += len + 1;
} while (i < end);
Expand Down
1 change: 1 addition & 0 deletions drivers/media/pci/cx23885/cx23885-417.c
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,7 @@ int cx23885_417_register(struct cx23885_dev *dev)
q->mem_ops = &vb2_dma_sg_memops;
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock;
q->dev = &dev->pci->dev;

err = vb2_queue_init(q);
if (err < 0)
Expand Down
1 change: 1 addition & 0 deletions drivers/media/pci/saa7134/saa7134-dvb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@ static int dvb_init(struct saa7134_dev *dev)
q->buf_struct_size = sizeof(struct saa7134_buf);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock;
q->dev = &dev->pci->dev;
ret = vb2_queue_init(q);
if (ret) {
vb2_dvb_dealloc_frontends(&dev->frontends);
Expand Down
1 change: 1 addition & 0 deletions drivers/media/pci/saa7134/saa7134-empress.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ static int empress_init(struct saa7134_dev *dev)
q->buf_struct_size = sizeof(struct saa7134_buf);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q);
if (err)
return err;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/platform/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ config VIDEO_MEDIATEK_VPU
config VIDEO_MEDIATEK_VCODEC
tristate "Mediatek Video Codec driver"
depends on MTK_IOMMU || COMPILE_TEST
depends on VIDEO_DEV && VIDEO_V4L2
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
depends on ARCH_MEDIATEK || COMPILE_TEST
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
Expand Down
1 change: 0 additions & 1 deletion drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-core.h>

#include "mtk_vcodec_util.h"

#define MTK_VCODEC_DRV_NAME "mtk_vcodec_drv"
#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc"
Expand Down
42 changes: 26 additions & 16 deletions drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
struct mtk_q_data *q_data;
int ret, i;
struct mtk_video_fmt *fmt;
unsigned int pitch_w_div16;
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;

vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
Expand Down Expand Up @@ -530,15 +529,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
q_data->coded_width = f->fmt.pix_mp.width;
q_data->coded_height = f->fmt.pix_mp.height;

pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
if (pitch_w_div16 % 8 != 0) {
/* Adjust returned width/height, so application could correctly
* allocate hw required memory
*/
q_data->visible_height += 32;
vidioc_try_fmt(f, q_data->fmt);
}

q_data->field = f->fmt.pix_mp.field;
ctx->colorspace = f->fmt.pix_mp.colorspace;
ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
Expand Down Expand Up @@ -878,7 +868,8 @@ static int mtk_venc_encode_header(void *priv)
{
struct mtk_vcodec_ctx *ctx = priv;
int ret;
struct vb2_buffer *dst_buf;
struct vb2_buffer *src_buf, *dst_buf;
struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result;

Expand Down Expand Up @@ -911,6 +902,15 @@ static int mtk_venc_encode_header(void *priv)
mtk_v4l2_err("venc_if_encode failed=%d", ret);
return -EINVAL;
}
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
if (src_buf) {
src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
dst_buf->timestamp = src_buf->timestamp;
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
} else {
mtk_v4l2_err("No timestamp for the header buffer.");
}

ctx->state = MTK_STATE_HEADER;
dst_buf->planes[0].bytesused = enc_result.bs_size;
Expand Down Expand Up @@ -1003,7 +1003,7 @@ static void mtk_venc_worker(struct work_struct *work)
struct mtk_vcodec_mem bs_buf;
struct venc_done_result enc_result;
int ret, i;
struct vb2_v4l2_buffer *vb2_v4l2;
struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;

/* check dst_buf, dst_buf may be removed in device_run
* to stored encdoe header so we need check dst_buf and
Expand Down Expand Up @@ -1043,9 +1043,14 @@ static void mtk_venc_worker(struct work_struct *work)
ret = venc_if_encode(ctx, VENC_START_OPT_ENCODE_FRAME,
&frm_buf, &bs_buf, &enc_result);

vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf);
src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);

dst_buf->timestamp = src_buf->timestamp;
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;

if (enc_result.is_key_frm)
vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;

if (ret) {
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
Expand Down Expand Up @@ -1217,7 +1222,7 @@ int mtk_vcodec_enc_ctrls_setup(struct mtk_vcodec_ctx *ctx)
0, V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE);
v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_PROFILE,
V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
0, V4L2_MPEG_VIDEO_H264_PROFILE_MAIN);
0, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH);
v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_LEVEL,
V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
0, V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
Expand Down Expand Up @@ -1288,5 +1293,10 @@ int mtk_venc_lock(struct mtk_vcodec_ctx *ctx)

void mtk_vcodec_enc_release(struct mtk_vcodec_ctx *ctx)
{
venc_if_deinit(ctx);
int ret = venc_if_deinit(ctx);

if (ret)
mtk_v4l2_err("venc_if_deinit failed=%d", ret);

ctx->state = MTK_STATE_FREE;
}
6 changes: 5 additions & 1 deletion drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,15 @@ static int fops_vcodec_release(struct file *file)
mtk_v4l2_debug(1, "[%d] encoder", ctx->id);
mutex_lock(&dev->dev_mutex);

/*
* Call v4l2_m2m_ctx_release to make sure the worker thread is not
* running after venc_if_deinit.
*/
v4l2_m2m_ctx_release(ctx->m2m_ctx);
mtk_vcodec_enc_release(ctx);
v4l2_fh_del(&ctx->fh);
v4l2_fh_exit(&ctx->fh);
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
v4l2_m2m_ctx_release(ctx->m2m_ctx);

list_del_init(&ctx->list);
dev->num_instances--;
Expand Down
1 change: 0 additions & 1 deletion drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#define _MTK_VCODEC_INTR_H_

#define MTK_INST_IRQ_RECEIVED 0x1
#define MTK_INST_WORK_THREAD_ABORT_DONE 0x2

struct mtk_vcodec_ctx;

Expand Down
16 changes: 8 additions & 8 deletions drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ enum venc_h264_bs_mode {

/*
* struct venc_h264_vpu_config - Structure for h264 encoder configuration
* AP-W/R : AP is writer/reader on this item
* VPU-W/R: VPU is write/reader on this item
* @input_fourcc: input fourcc
* @bitrate: target bitrate (in bps)
* @pic_w: picture width. Picture size is visible stream resolution, in pixels,
Expand Down Expand Up @@ -94,20 +96,22 @@ struct venc_h264_vpu_config {

/*
* struct venc_h264_vpu_buf - Structure for buffer information
* @align: buffer alignment (in bytes)
* AP-W/R : AP is writer/reader on this item
* VPU-W/R: VPU is write/reader on this item
* @iova: IO virtual address
* @vpua: VPU side memory addr which is used by RC_CODE
* @size: buffer size (in bytes)
*/
struct venc_h264_vpu_buf {
u32 align;
u32 iova;
u32 vpua;
u32 size;
};

/*
* struct venc_h264_vsi - Structure for VPU driver control and info share
* AP-W/R : AP is writer/reader on this item
* VPU-W/R: VPU is write/reader on this item
* This structure is allocated in VPU side and shared to AP side.
* @config: h264 encoder configuration
* @work_bufs: working buffer information in VPU side
Expand Down Expand Up @@ -150,12 +154,6 @@ struct venc_h264_inst {
struct mtk_vcodec_ctx *ctx;
};

static inline void h264_write_reg(struct venc_h264_inst *inst, u32 addr,
u32 val)
{
writel(val, inst->hw_base + addr);
}

static inline u32 h264_read_reg(struct venc_h264_inst *inst, u32 addr)
{
return readl(inst->hw_base + addr);
Expand Down Expand Up @@ -214,6 +212,8 @@ static unsigned int h264_get_level(struct venc_h264_inst *inst,
return 40;
case V4L2_MPEG_VIDEO_H264_LEVEL_4_1:
return 41;
case V4L2_MPEG_VIDEO_H264_LEVEL_4_2:
return 42;
default:
mtk_vcodec_debug(inst, "unsupported level %d", level);
return 31;
Expand Down
16 changes: 7 additions & 9 deletions drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ enum venc_vp8_vpu_work_buf {

/*
* struct venc_vp8_vpu_config - Structure for vp8 encoder configuration
* AP-W/R : AP is writer/reader on this item
* VPU-W/R: VPU is write/reader on this item
* @input_fourcc: input fourcc
* @bitrate: target bitrate (in bps)
* @pic_w: picture width. Picture size is visible stream resolution, in pixels,
Expand Down Expand Up @@ -83,21 +85,23 @@ struct venc_vp8_vpu_config {
};

/*
* struct venc_vp8_vpu_buf -Structure for buffer information
* @align: buffer alignment (in bytes)
* struct venc_vp8_vpu_buf - Structure for buffer information
* AP-W/R : AP is writer/reader on this item
* VPU-W/R: VPU is write/reader on this item
* @iova: IO virtual address
* @vpua: VPU side memory addr which is used by RC_CODE
* @size: buffer size (in bytes)
*/
struct venc_vp8_vpu_buf {
u32 align;
u32 iova;
u32 vpua;
u32 size;
};

/*
* struct venc_vp8_vsi - Structure for VPU driver control and info share
* AP-W/R : AP is writer/reader on this item
* VPU-W/R: VPU is write/reader on this item
* This structure is allocated in VPU side and shared to AP side.
* @config: vp8 encoder configuration
* @work_bufs: working buffer information in VPU side
Expand Down Expand Up @@ -138,12 +142,6 @@ struct venc_vp8_inst {
struct mtk_vcodec_ctx *ctx;
};

static inline void vp8_enc_write_reg(struct venc_vp8_inst *inst, u32 addr,
u32 val)
{
writel(val, inst->hw_base + addr);
}

static inline u32 vp8_enc_read_reg(struct venc_vp8_inst *inst, u32 addr)
{
return readl(inst->hw_base + addr);
Expand Down
8 changes: 7 additions & 1 deletion drivers/media/platform/rcar-fcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,16 @@ EXPORT_SYMBOL_GPL(rcar_fcp_put);
*/
int rcar_fcp_enable(struct rcar_fcp_device *fcp)
{
int error;

if (!fcp)
return 0;

return pm_runtime_get_sync(fcp->dev);
error = pm_runtime_get_sync(fcp->dev);
if (error < 0)
return error;

return 0;
}
EXPORT_SYMBOL_GPL(rcar_fcp_enable);

Expand Down
1 change: 1 addition & 0 deletions drivers/staging/media/cec/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Hopefully this will happen later in 2016.

Other TODOs:

- There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
- Add a flag to inhibit passing CEC RC messages to the rc subsystem.
Applications should be able to choose this when calling S_LOG_ADDRS.
- If the reply field of cec_msg is set then when the reply arrives it
Expand Down
Loading

0 comments on commit b1f2beb

Please sign in to comment.