Merge tag 'media/v5.10-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 10 Dec 2020 18:48:49 +0000 (10:48 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 10 Dec 2020 18:48:49 +0000 (10:48 -0800)
Pull media fixes from Mauro Carvalho Chehab:
 "A couple of fixes:

   - videobuf2: fix a DMABUF bug, preventing it to properly handle cache
     sync/flush

   - vidtv: an usage after free and a few sparse/smatch warning fixes

   - pulse8-cec: a duplicate free and a bug related to new firmware
     usage

   - mtk-cir: fix a regression on a clock setting"

* tag 'media/v5.10-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
  media: vidtv: fix some warnings
  media: vidtv: fix kernel-doc markups
  media: [next] media: vidtv: fix a read from an object after it has been freed
  media: vb2: set cache sync hints when init buffers
  media: pulse8-cec: add support for FW v10 and up
  media: pulse8-cec: fix duplicate free at disconnect or probe error
  media: mtk-cir: fix calculation of chk period

drivers/media/cec/usb/pulse8/pulse8-cec.c
drivers/media/common/videobuf2/videobuf2-core.c
drivers/media/rc/mtk-cir.c
drivers/media/test-drivers/vidtv/vidtv_channel.c
drivers/media/test-drivers/vidtv/vidtv_psi.h
drivers/media/test-drivers/vidtv/vidtv_s302m.c
drivers/media/test-drivers/vidtv/vidtv_ts.h

index e4d8446b87da94d1219bafb09101c0e0a66daf69..04b13cdc38d2c6f554980e6536d117861bb78575 100644 (file)
@@ -88,13 +88,15 @@ enum pulse8_msgcodes {
        MSGCODE_SET_PHYSICAL_ADDRESS,   /* 0x20 */
        MSGCODE_GET_DEVICE_TYPE,
        MSGCODE_SET_DEVICE_TYPE,
-       MSGCODE_GET_HDMI_VERSION,
+       MSGCODE_GET_HDMI_VERSION,       /* Removed in FW >= 10 */
        MSGCODE_SET_HDMI_VERSION,
        MSGCODE_GET_OSD_NAME,
        MSGCODE_SET_OSD_NAME,
        MSGCODE_WRITE_EEPROM,
        MSGCODE_GET_ADAPTER_TYPE,       /* 0x28 */
        MSGCODE_SET_ACTIVE_SOURCE,
+       MSGCODE_GET_AUTO_POWER_ON,      /* New for FW >= 10 */
+       MSGCODE_SET_AUTO_POWER_ON,
 
        MSGCODE_FRAME_EOM = 0x80,
        MSGCODE_FRAME_ACK = 0x40,
@@ -143,6 +145,8 @@ static const char * const pulse8_msgnames[] = {
        "WRITE_EEPROM",
        "GET_ADAPTER_TYPE",
        "SET_ACTIVE_SOURCE",
+       "GET_AUTO_POWER_ON",
+       "SET_AUTO_POWER_ON",
 };
 
 static const char *pulse8_msgname(u8 cmd)
@@ -579,12 +583,14 @@ static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
        if (err)
                goto unlock;
 
-       cmd[0] = MSGCODE_SET_HDMI_VERSION;
-       cmd[1] = adap->log_addrs.cec_version;
-       err = pulse8_send_and_wait(pulse8, cmd, 2,
-                                  MSGCODE_COMMAND_ACCEPTED, 0);
-       if (err)
-               goto unlock;
+       if (pulse8->vers < 10) {
+               cmd[0] = MSGCODE_SET_HDMI_VERSION;
+               cmd[1] = adap->log_addrs.cec_version;
+               err = pulse8_send_and_wait(pulse8, cmd, 2,
+                                          MSGCODE_COMMAND_ACCEPTED, 0);
+               if (err)
+                       goto unlock;
+       }
 
        if (adap->log_addrs.osd_name[0]) {
                size_t osd_len = strlen(adap->log_addrs.osd_name);
@@ -650,7 +656,6 @@ static void pulse8_disconnect(struct serio *serio)
        struct pulse8 *pulse8 = serio_get_drvdata(serio);
 
        cec_unregister_adapter(pulse8->adap);
-       pulse8->serio = NULL;
        serio_set_drvdata(serio, NULL);
        serio_close(serio);
 }
@@ -692,6 +697,14 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
        dev_dbg(pulse8->dev, "Autonomous mode: %s",
                data[0] ? "on" : "off");
 
+       if (pulse8->vers >= 10) {
+               cmd[0] = MSGCODE_GET_AUTO_POWER_ON;
+               err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 1);
+               if (!err)
+                       dev_dbg(pulse8->dev, "Auto Power On: %s",
+                               data[0] ? "on" : "off");
+       }
+
        cmd[0] = MSGCODE_GET_DEVICE_TYPE;
        err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 1);
        if (err)
@@ -753,12 +766,15 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
        dev_dbg(pulse8->dev, "Physical address: %x.%x.%x.%x\n",
                cec_phys_addr_exp(*pa));
 
-       cmd[0] = MSGCODE_GET_HDMI_VERSION;
-       err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 1);
-       if (err)
-               return err;
-       log_addrs->cec_version = data[0];
-       dev_dbg(pulse8->dev, "CEC version: %d\n", log_addrs->cec_version);
+       log_addrs->cec_version = CEC_OP_CEC_VERSION_1_4;
+       if (pulse8->vers < 10) {
+               cmd[0] = MSGCODE_GET_HDMI_VERSION;
+               err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 1);
+               if (err)
+                       return err;
+               log_addrs->cec_version = data[0];
+               dev_dbg(pulse8->dev, "CEC version: %d\n", log_addrs->cec_version);
+       }
 
        cmd[0] = MSGCODE_GET_OSD_NAME;
        err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 0);
@@ -830,8 +846,10 @@ static int pulse8_connect(struct serio *serio, struct serio_driver *drv)
        pulse8->adap = cec_allocate_adapter(&pulse8_cec_adap_ops, pulse8,
                                            dev_name(&serio->dev), caps, 1);
        err = PTR_ERR_OR_ZERO(pulse8->adap);
-       if (err < 0)
-               goto free_device;
+       if (err < 0) {
+               kfree(pulse8);
+               return err;
+       }
 
        pulse8->dev = &serio->dev;
        serio_set_drvdata(serio, pulse8);
@@ -874,8 +892,6 @@ close_serio:
        serio_close(serio);
 delete_adap:
        cec_delete_adapter(pulse8->adap);
-free_device:
-       kfree(pulse8);
        return err;
 }
 
index 4eab6d81cce170f4c708cd14ed10b017db8cc761..89e38392509c12c68b9056a60ef942b38854c18e 100644 (file)
@@ -414,6 +414,17 @@ static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
                vb->index = q->num_buffers + buffer;
                vb->type = q->type;
                vb->memory = memory;
+               /*
+                * We need to set these flags here so that the videobuf2 core
+                * will call ->prepare()/->finish() cache sync/flush on vb2
+                * buffers when appropriate. However, we can avoid explicit
+                * ->prepare() and ->finish() cache sync for DMABUF buffers,
+                * because DMA exporter takes care of it.
+                */
+               if (q->memory != VB2_MEMORY_DMABUF) {
+                       vb->need_cache_sync_on_prepare = 1;
+                       vb->need_cache_sync_on_finish = 1;
+               }
                for (plane = 0; plane < num_planes; ++plane) {
                        vb->planes[plane].length = plane_sizes[plane];
                        vb->planes[plane].min_length = plane_sizes[plane];
index 5051a5e5244beb6c04da4d00284b616daca01a30..65a136c0fac25f22258fe27b63827f83edb72834 100644 (file)
@@ -151,15 +151,12 @@ static inline u32 mtk_chk_period(struct mtk_ir *ir)
 {
        u32 val;
 
-       /* Period of raw software sampling in ns */
-       val = DIV_ROUND_CLOSEST(1000000000ul,
-                               clk_get_rate(ir->bus) / ir->data->div);
-
        /*
         * Period for software decoder used in the
         * unit of raw software sampling
         */
-       val = DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, val);
+       val = DIV_ROUND_CLOSEST(clk_get_rate(ir->bus),
+                               USEC_PER_SEC * ir->data->div / MTK_IR_SAMPLE);
 
        dev_dbg(ir->dev, "@pwm clk  = \t%lu\n",
                clk_get_rate(ir->bus) / ir->data->div);
@@ -412,7 +409,7 @@ static int mtk_ir_probe(struct platform_device *pdev)
        mtk_irq_enable(ir, MTK_IRINT_EN);
 
        dev_info(dev, "Initialized MT7623 IR driver, sample period = %dus\n",
-                DIV_ROUND_CLOSEST(MTK_IR_SAMPLE, 1000));
+                MTK_IR_SAMPLE);
 
        return 0;
 
index 8ad6c0744d36306e8dbc5a839828b915be8aaa54..7838e62727128fca89e07cfa691b7671f3cf0e58 100644 (file)
@@ -504,11 +504,11 @@ void vidtv_channel_si_destroy(struct vidtv_mux *m)
 {
        u32 i;
 
-       vidtv_psi_pat_table_destroy(m->si.pat);
-
        for (i = 0; i < m->si.pat->num_pmt; ++i)
                vidtv_psi_pmt_table_destroy(m->si.pmt_secs[i]);
 
+       vidtv_psi_pat_table_destroy(m->si.pat);
+
        kfree(m->si.pmt_secs);
        vidtv_psi_sdt_table_destroy(m->si.sdt);
        vidtv_psi_nit_table_destroy(m->si.nit);
index 340c9fb8d583e20fe4695411ee62f4c325805f7e..fdc825e54138e47a2a7164e2e75319fcac496cee 100644 (file)
@@ -420,7 +420,7 @@ void vidtv_psi_desc_assign(struct vidtv_psi_desc **to,
                           struct vidtv_psi_desc *desc);
 
 /**
- * vidtv_psi_pmt_desc_assign - Assigns a descriptor loop at some point in a PMT section.
+ * vidtv_pmt_desc_assign - Assigns a descriptor loop at some point in a PMT section.
  * @pmt: The PMT section that will contain the descriptor loop
  * @to: Where in the PMT to assign this descriptor loop to
  * @desc: The descriptor loop that will be assigned.
@@ -434,7 +434,7 @@ void vidtv_pmt_desc_assign(struct vidtv_psi_table_pmt *pmt,
                           struct vidtv_psi_desc *desc);
 
 /**
- * vidtv_psi_sdt_desc_assign - Assigns a descriptor loop at some point in a SDT.
+ * vidtv_sdt_desc_assign - Assigns a descriptor loop at some point in a SDT.
  * @sdt: The SDT that will contain the descriptor loop
  * @to: Where in the PMT to assign this descriptor loop to
  * @desc: The descriptor loop that will be assigned.
@@ -474,7 +474,7 @@ void vidtv_psi_pmt_stream_assign(struct vidtv_psi_table_pmt *pmt,
 struct vidtv_psi_desc *vidtv_psi_desc_clone(struct vidtv_psi_desc *desc);
 
 /**
- * vidtv_psi_create_sec_for_each_pat_entry - Create a PMT section for each
+ * vidtv_psi_pmt_create_sec_for_each_pat_entry - Create a PMT section for each
  * program found in the PAT
  * @pat: The PAT to look for programs.
  * @pcr_pid: packet ID for the PCR to be used for the program described in this
@@ -743,7 +743,7 @@ struct vidtv_psi_table_eit {
 struct vidtv_psi_table_eit
 *vidtv_psi_eit_table_init(u16 network_id,
                          u16 transport_stream_id,
-                         u16 service_id);
+                         __be16 service_id);
 
 /**
  * struct vidtv_psi_eit_write_args - Arguments for writing an EIT section
index ce7dd6cafc8b778da072821586b443afff7f1467..d79b65854627cc18c60c5172430c40369e687c68 100644 (file)
@@ -467,8 +467,10 @@ struct vidtv_encoder
        e->is_video_encoder = false;
 
        ctx = kzalloc(priv_sz, GFP_KERNEL);
-       if (!ctx)
+       if (!ctx) {
+               kfree(e);
                return NULL;
+       }
 
        e->ctx = ctx;
        ctx->last_duration = 0;
index 10838a2b8389d018dec14ae10828c0d008a73f1c..f5e8e1f37f0521f5dd3a8ce0813122efb007a2a1 100644 (file)
@@ -44,7 +44,7 @@ struct vidtv_mpeg_ts {
                u8 adaptation_field:1;
                u8 scrambling:2;
        } __packed;
-       struct vidtv_mpeg_ts_adaption adaption[];
+       struct vidtv_mpeg_ts_adaption *adaption;
 } __packed;
 
 /**