Skip to content

Commit b1f2beb

Browse files
committed
Merge tag 'media/v4.8-7' of git://git.kernel.org/pub/scm/linux/kernel/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 ...
2 parents f887c21 + d8feef9 commit b1f2beb

File tree

22 files changed

+212
-78
lines changed

22 files changed

+212
-78
lines changed

Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ logical address types are already defined will return with error ``EBUSY``.
144144

145145
- ``flags``
146146

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

149149
- .. row 7
150150

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

204+
.. _cec-log-addrs-flags:
205+
206+
.. flat-table:: Flags for struct cec_log_addrs
207+
:header-rows: 0
208+
:stub-columns: 0
209+
:widths: 3 1 4
210+
211+
212+
- .. _`CEC-LOG-ADDRS-FL-ALLOW-UNREG-FALLBACK`:
213+
214+
- ``CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK``
215+
216+
- 1
217+
218+
- By default if no logical address of the requested type can be claimed, then
219+
it will go back to the unconfigured state. If this flag is set, then it will
220+
fallback to the Unregistered logical address. Note that if the Unregistered
221+
logical address was explicitly requested, then this flag has no effect.
222+
204223
.. _cec-versions:
205224

206225
.. flat-table:: CEC Versions

Documentation/media/uapi/cec/cec-ioc-dqevent.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ it is guaranteed that the state did change in between the two events.
6464

6565
- ``phys_addr``
6666

67-
- The current physical address.
67+
- The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no
68+
valid physical address is set.
6869

6970
- .. row 2
7071

7172
- __u16
7273

7374
- ``log_addr_mask``
7475

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

7781

7882

drivers/media/cec-edid.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ static unsigned int cec_get_edid_spa_location(const u8 *edid, unsigned int size)
7070
u8 tag = edid[i] >> 5;
7171
u8 len = edid[i] & 0x1f;
7272

73-
if (tag == 3 && len >= 5 && i + len <= end)
73+
if (tag == 3 && len >= 5 && i + len <= end &&
74+
edid[i + 1] == 0x03 &&
75+
edid[i + 2] == 0x0c &&
76+
edid[i + 3] == 0x00)
7477
return i + 4;
7578
i += len + 1;
7679
} while (i < end);

drivers/media/pci/cx23885/cx23885-417.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ int cx23885_417_register(struct cx23885_dev *dev)
15521552
q->mem_ops = &vb2_dma_sg_memops;
15531553
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
15541554
q->lock = &dev->lock;
1555+
q->dev = &dev->pci->dev;
15551556

15561557
err = vb2_queue_init(q);
15571558
if (err < 0)

drivers/media/pci/saa7134/saa7134-dvb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,6 +1238,7 @@ static int dvb_init(struct saa7134_dev *dev)
12381238
q->buf_struct_size = sizeof(struct saa7134_buf);
12391239
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
12401240
q->lock = &dev->lock;
1241+
q->dev = &dev->pci->dev;
12411242
ret = vb2_queue_init(q);
12421243
if (ret) {
12431244
vb2_dvb_dealloc_frontends(&dev->frontends);

drivers/media/pci/saa7134/saa7134-empress.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ static int empress_init(struct saa7134_dev *dev)
295295
q->buf_struct_size = sizeof(struct saa7134_buf);
296296
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
297297
q->lock = &dev->lock;
298+
q->dev = &dev->pci->dev;
298299
err = vb2_queue_init(q);
299300
if (err)
300301
return err;

drivers/media/platform/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ config VIDEO_MEDIATEK_VPU
169169
config VIDEO_MEDIATEK_VCODEC
170170
tristate "Mediatek Video Codec driver"
171171
depends on MTK_IOMMU || COMPILE_TEST
172-
depends on VIDEO_DEV && VIDEO_V4L2
172+
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
173173
depends on ARCH_MEDIATEK || COMPILE_TEST
174174
select VIDEOBUF2_DMA_CONTIG
175175
select V4L2_MEM2MEM_DEV

drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <media/v4l2-ioctl.h>
2424
#include <media/videobuf2-core.h>
2525

26-
#include "mtk_vcodec_util.h"
2726

2827
#define MTK_VCODEC_DRV_NAME "mtk_vcodec_drv"
2928
#define MTK_VCODEC_ENC_NAME "mtk-vcodec-enc"

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
487487
struct mtk_q_data *q_data;
488488
int ret, i;
489489
struct mtk_video_fmt *fmt;
490-
unsigned int pitch_w_div16;
491490
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
492491

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

533-
pitch_w_div16 = DIV_ROUND_UP(q_data->visible_width, 16);
534-
if (pitch_w_div16 % 8 != 0) {
535-
/* Adjust returned width/height, so application could correctly
536-
* allocate hw required memory
537-
*/
538-
q_data->visible_height += 32;
539-
vidioc_try_fmt(f, q_data->fmt);
540-
}
541-
542532
q_data->field = f->fmt.pix_mp.field;
543533
ctx->colorspace = f->fmt.pix_mp.colorspace;
544534
ctx->ycbcr_enc = f->fmt.pix_mp.ycbcr_enc;
@@ -878,7 +868,8 @@ static int mtk_venc_encode_header(void *priv)
878868
{
879869
struct mtk_vcodec_ctx *ctx = priv;
880870
int ret;
881-
struct vb2_buffer *dst_buf;
871+
struct vb2_buffer *src_buf, *dst_buf;
872+
struct vb2_v4l2_buffer *dst_vb2_v4l2, *src_vb2_v4l2;
882873
struct mtk_vcodec_mem bs_buf;
883874
struct venc_done_result enc_result;
884875

@@ -911,6 +902,15 @@ static int mtk_venc_encode_header(void *priv)
911902
mtk_v4l2_err("venc_if_encode failed=%d", ret);
912903
return -EINVAL;
913904
}
905+
src_buf = v4l2_m2m_next_src_buf(ctx->m2m_ctx);
906+
if (src_buf) {
907+
src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
908+
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
909+
dst_buf->timestamp = src_buf->timestamp;
910+
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
911+
} else {
912+
mtk_v4l2_err("No timestamp for the header buffer.");
913+
}
914914

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

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

1046-
vb2_v4l2 = container_of(dst_buf, struct vb2_v4l2_buffer, vb2_buf);
1046+
src_vb2_v4l2 = to_vb2_v4l2_buffer(src_buf);
1047+
dst_vb2_v4l2 = to_vb2_v4l2_buffer(dst_buf);
1048+
1049+
dst_buf->timestamp = src_buf->timestamp;
1050+
dst_vb2_v4l2->timecode = src_vb2_v4l2->timecode;
1051+
10471052
if (enc_result.is_key_frm)
1048-
vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
1053+
dst_vb2_v4l2->flags |= V4L2_BUF_FLAG_KEYFRAME;
10491054

10501055
if (ret) {
10511056
v4l2_m2m_buf_done(to_vb2_v4l2_buffer(src_buf),
@@ -1217,7 +1222,7 @@ int mtk_vcodec_enc_ctrls_setup(struct mtk_vcodec_ctx *ctx)
12171222
0, V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE);
12181223
v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_PROFILE,
12191224
V4L2_MPEG_VIDEO_H264_PROFILE_HIGH,
1220-
0, V4L2_MPEG_VIDEO_H264_PROFILE_MAIN);
1225+
0, V4L2_MPEG_VIDEO_H264_PROFILE_HIGH);
12211226
v4l2_ctrl_new_std_menu(handler, ops, V4L2_CID_MPEG_VIDEO_H264_LEVEL,
12221227
V4L2_MPEG_VIDEO_H264_LEVEL_4_2,
12231228
0, V4L2_MPEG_VIDEO_H264_LEVEL_4_0);
@@ -1288,5 +1293,10 @@ int mtk_venc_lock(struct mtk_vcodec_ctx *ctx)
12881293

12891294
void mtk_vcodec_enc_release(struct mtk_vcodec_ctx *ctx)
12901295
{
1291-
venc_if_deinit(ctx);
1296+
int ret = venc_if_deinit(ctx);
1297+
1298+
if (ret)
1299+
mtk_v4l2_err("venc_if_deinit failed=%d", ret);
1300+
1301+
ctx->state = MTK_STATE_FREE;
12921302
}

drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,15 @@ static int fops_vcodec_release(struct file *file)
218218
mtk_v4l2_debug(1, "[%d] encoder", ctx->id);
219219
mutex_lock(&dev->dev_mutex);
220220

221+
/*
222+
* Call v4l2_m2m_ctx_release to make sure the worker thread is not
223+
* running after venc_if_deinit.
224+
*/
225+
v4l2_m2m_ctx_release(ctx->m2m_ctx);
221226
mtk_vcodec_enc_release(ctx);
222227
v4l2_fh_del(&ctx->fh);
223228
v4l2_fh_exit(&ctx->fh);
224229
v4l2_ctrl_handler_free(&ctx->ctrl_hdl);
225-
v4l2_m2m_ctx_release(ctx->m2m_ctx);
226230

227231
list_del_init(&ctx->list);
228232
dev->num_instances--;

drivers/media/platform/mtk-vcodec/mtk_vcodec_intr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define _MTK_VCODEC_INTR_H_
1717

1818
#define MTK_INST_IRQ_RECEIVED 0x1
19-
#define MTK_INST_WORK_THREAD_ABORT_DONE 0x2
2019

2120
struct mtk_vcodec_ctx;
2221

drivers/media/platform/mtk-vcodec/venc/venc_h264_if.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ enum venc_h264_bs_mode {
6161

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

9597
/*
9698
* struct venc_h264_vpu_buf - Structure for buffer information
97-
* @align: buffer alignment (in bytes)
99+
* AP-W/R : AP is writer/reader on this item
100+
* VPU-W/R: VPU is write/reader on this item
98101
* @iova: IO virtual address
99102
* @vpua: VPU side memory addr which is used by RC_CODE
100103
* @size: buffer size (in bytes)
101104
*/
102105
struct venc_h264_vpu_buf {
103-
u32 align;
104106
u32 iova;
105107
u32 vpua;
106108
u32 size;
107109
};
108110

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

153-
static inline void h264_write_reg(struct venc_h264_inst *inst, u32 addr,
154-
u32 val)
155-
{
156-
writel(val, inst->hw_base + addr);
157-
}
158-
159157
static inline u32 h264_read_reg(struct venc_h264_inst *inst, u32 addr)
160158
{
161159
return readl(inst->hw_base + addr);
@@ -214,6 +212,8 @@ static unsigned int h264_get_level(struct venc_h264_inst *inst,
214212
return 40;
215213
case V4L2_MPEG_VIDEO_H264_LEVEL_4_1:
216214
return 41;
215+
case V4L2_MPEG_VIDEO_H264_LEVEL_4_2:
216+
return 42;
217217
default:
218218
mtk_vcodec_debug(inst, "unsupported level %d", level);
219219
return 31;

drivers/media/platform/mtk-vcodec/venc/venc_vp8_if.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ enum venc_vp8_vpu_work_buf {
5656

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

8587
/*
86-
* struct venc_vp8_vpu_buf -Structure for buffer information
87-
* @align: buffer alignment (in bytes)
88+
* struct venc_vp8_vpu_buf - Structure for buffer information
89+
* AP-W/R : AP is writer/reader on this item
90+
* VPU-W/R: VPU is write/reader on this item
8891
* @iova: IO virtual address
8992
* @vpua: VPU side memory addr which is used by RC_CODE
9093
* @size: buffer size (in bytes)
9194
*/
9295
struct venc_vp8_vpu_buf {
93-
u32 align;
9496
u32 iova;
9597
u32 vpua;
9698
u32 size;
9799
};
98100

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

141-
static inline void vp8_enc_write_reg(struct venc_vp8_inst *inst, u32 addr,
142-
u32 val)
143-
{
144-
writel(val, inst->hw_base + addr);
145-
}
146-
147145
static inline u32 vp8_enc_read_reg(struct venc_vp8_inst *inst, u32 addr)
148146
{
149147
return readl(inst->hw_base + addr);

drivers/media/platform/rcar-fcp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@ EXPORT_SYMBOL_GPL(rcar_fcp_put);
9999
*/
100100
int rcar_fcp_enable(struct rcar_fcp_device *fcp)
101101
{
102+
int error;
103+
102104
if (!fcp)
103105
return 0;
104106

105-
return pm_runtime_get_sync(fcp->dev);
107+
error = pm_runtime_get_sync(fcp->dev);
108+
if (error < 0)
109+
return error;
110+
111+
return 0;
106112
}
107113
EXPORT_SYMBOL_GPL(rcar_fcp_enable);
108114

drivers/staging/media/cec/TODO

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Hopefully this will happen later in 2016.
1212

1313
Other TODOs:
1414

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

0 commit comments

Comments
 (0)