From: johan.korsnes@gmail.com
To: linux-media@vger.kernel.org
Cc: Johan Korsnes <johan.korsnes@gmail.com>
Subject: [PATCH 7/8] media: vivid: add CEC support to display present ctrl
Date: Tue, 28 May 2019 10:19:11 -0700 [thread overview]
Message-ID: <20190528171912.3688-8-johan.korsnes@gmail.com> (raw)
In-Reply-To: <20190528171912.3688-1-johan.korsnes@gmail.com>
From: Johan Korsnes <johan.korsnes@gmail.com>
Set/invalidate physical addresses based on the configuration of the
display present control. This is relevant not only when the display
present control is modified, but also when the Vivid instance EDID is
set/cleared.
Signed-off-by: Johan Korsnes <johan.korsnes@gmail.com>
---
drivers/media/platform/vivid/vivid-core.c | 16 ++++++------
drivers/media/platform/vivid/vivid-ctrls.c | 25 ++++++++++++++++---
drivers/media/platform/vivid/vivid-vid-cap.c | 6 ++++-
.../media/platform/vivid/vivid-vid-common.c | 2 ++
4 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c
index b2b4ee48cef0..ca46ac24f51e 100644
--- a/drivers/media/platform/vivid/vivid-core.c
+++ b/drivers/media/platform/vivid/vivid-core.c
@@ -1060,14 +1060,6 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
vivid_update_format_cap(dev, false);
vivid_update_format_out(dev);
- v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vid_cap);
- v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vid_out);
- v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vbi_cap);
- v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vbi_out);
- v4l2_ctrl_handler_setup(&dev->ctrl_hdl_radio_rx);
- v4l2_ctrl_handler_setup(&dev->ctrl_hdl_radio_tx);
- v4l2_ctrl_handler_setup(&dev->ctrl_hdl_sdr_cap);
-
/* initialize overlay */
dev->fb_cap.fmt.width = dev->src_rect.width;
dev->fb_cap.fmt.height = dev->src_rect.height;
@@ -1488,6 +1480,14 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
}
#endif
+ v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vid_cap);
+ v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vid_out);
+ v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vbi_cap);
+ v4l2_ctrl_handler_setup(&dev->ctrl_hdl_vbi_out);
+ v4l2_ctrl_handler_setup(&dev->ctrl_hdl_radio_rx);
+ v4l2_ctrl_handler_setup(&dev->ctrl_hdl_radio_tx);
+ v4l2_ctrl_handler_setup(&dev->ctrl_hdl_sdr_cap);
+
/* Now that everything is fine, let's add it to device list */
vivid_devs[inst] = dev;
diff --git a/drivers/media/platform/vivid/vivid-ctrls.c b/drivers/media/platform/vivid/vivid-ctrls.c
index ae3690fd1b52..e4758a2837e6 100644
--- a/drivers/media/platform/vivid/vivid-ctrls.c
+++ b/drivers/media/platform/vivid/vivid-ctrls.c
@@ -18,6 +18,7 @@
#include "vivid-radio-common.h"
#include "vivid-osd.h"
#include "vivid-ctrls.h"
+#include "vivid-cec.h"
#define VIVID_CID_CUSTOM_BASE (V4L2_CID_USER_BASE | 0xf000)
#define VIVID_CID_BUTTON (VIVID_CID_CUSTOM_BASE + 0)
@@ -923,7 +924,7 @@ static int vivid_vid_out_s_ctrl(struct v4l2_ctrl *ctrl)
struct vivid_dev *dev = container_of(ctrl->handler, struct vivid_dev, ctrl_hdl_vid_out);
struct v4l2_bt_timings *bt = &dev->dv_timings_out.bt;
u32 display_present = 0;
- unsigned i, j;
+ unsigned i, j, bus_idx;
switch (ctrl->id) {
case VIVID_CID_HAS_CROP_OUT:
@@ -962,15 +963,31 @@ static int vivid_vid_out_s_ctrl(struct v4l2_ctrl *ctrl)
break;
dev->display_present[dev->output] = ctrl->val;
-
for (i = 0, j = 0; i < dev->num_outputs; i++)
if (dev->output_type[i] == HDMI)
display_present |=
dev->display_present[i] << j++;
- __v4l2_ctrl_s_ctrl(dev->ctrl_tx_hotplug, display_present);
__v4l2_ctrl_s_ctrl(dev->ctrl_tx_rxsense, display_present);
- __v4l2_ctrl_s_ctrl(dev->ctrl_tx_edid_present, display_present);
+
+ if (dev->edid_blocks) {
+ __v4l2_ctrl_s_ctrl(dev->ctrl_tx_edid_present,
+ display_present);
+ __v4l2_ctrl_s_ctrl(dev->ctrl_tx_hotplug,
+ display_present);
+ }
+
+ if (dev->cec_tx_adap == NULL)
+ break;
+
+ bus_idx = dev->cec_output2bus_map[dev->output];
+ if (ctrl->val && dev->edid_blocks)
+ cec_s_phys_addr(dev->cec_tx_adap[bus_idx],
+ dev->cec_tx_adap[bus_idx]->phys_addr,
+ false);
+ else
+ cec_phys_addr_invalidate(dev->cec_tx_adap[bus_idx]);
+
break;
}
return 0;
diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
index ca15c13abf6c..920be638da83 100644
--- a/drivers/media/platform/vivid/vivid-vid-cap.c
+++ b/drivers/media/platform/vivid/vivid-vid-cap.c
@@ -1760,6 +1760,7 @@ int vidioc_s_edid(struct file *file, void *_fh,
return -EINVAL;
if (edid->blocks == 0) {
dev->edid_blocks = 0;
+ v4l2_ctrl_s_ctrl(dev->ctrl_tx_edid_present, false);
phys_addr = CEC_PHYS_ADDR_INVALID;
goto set_phys_addr;
}
@@ -1777,6 +1778,7 @@ int vidioc_s_edid(struct file *file, void *_fh,
dev->edid_blocks = edid->blocks;
memcpy(dev->edid, edid->edid, edid->blocks * 128);
+ v4l2_ctrl_s_ctrl(dev->ctrl_tx_edid_present, true);
set_phys_addr:
/* TODO: a proper hotplug detect cycle should be emulated here */
@@ -1784,7 +1786,9 @@ int vidioc_s_edid(struct file *file, void *_fh,
for (i = 0; i < MAX_OUTPUTS && dev->cec_tx_adap[i]; i++)
cec_s_phys_addr(dev->cec_tx_adap[i],
- v4l2_phys_addr_for_input(phys_addr, i + 1),
+ dev->display_present[i] ?
+ v4l2_phys_addr_for_input(phys_addr, i + 1) :
+ CEC_PHYS_ADDR_INVALID,
false);
return 0;
}
diff --git a/drivers/media/platform/vivid/vivid-vid-common.c b/drivers/media/platform/vivid/vivid-vid-common.c
index b6882426fc12..0addf8ef7dbf 100644
--- a/drivers/media/platform/vivid/vivid-vid-common.c
+++ b/drivers/media/platform/vivid/vivid-vid-common.c
@@ -907,6 +907,8 @@ int vidioc_g_edid(struct file *file, void *_fh,
return -EINVAL;
if (dev->output_type[edid->pad] != HDMI)
return -EINVAL;
+ if (!dev->display_present[dev->output])
+ return -ENODATA;
bus_idx = dev->cec_output2bus_map[edid->pad];
adap = dev->cec_tx_adap[bus_idx];
}
--
2.17.1
next prev parent reply other threads:[~2019-05-28 16:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-28 17:19 vivid: Add HDMI (dis)connect emulation johan.korsnes
2019-05-28 17:19 ` [PATCH 1/8] media: vivid: make input dv_timings per-input johan.korsnes
2019-05-28 17:19 ` [PATCH 2/8] media: vivid: make input std_signal per-input johan.korsnes
2019-05-28 17:19 ` [PATCH 3/8] media: vivid: add display present control johan.korsnes
2019-05-28 17:19 ` [PATCH 4/8] media: vivid: add number of HDMI ports to device state johan.korsnes
2019-05-28 17:19 ` [PATCH 5/8] media: vivid: add HDMI (dis)connect TX emulation johan.korsnes
2019-05-28 17:19 ` [PATCH 6/8] media: vivid: add HDMI (dis)connect RX emulation johan.korsnes
2019-05-28 17:19 ` johan.korsnes [this message]
2019-05-29 7:39 ` [PATCH 7/8] media: vivid: add CEC support to display present ctrl Hans Verkuil
2019-06-11 20:25 ` Johan Korsnes
2019-06-11 20:45 ` Hans Verkuil
2019-05-28 17:19 ` [PATCH 8/8] media: vivid.rst: describe display present control johan.korsnes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190528171912.3688-8-johan.korsnes@gmail.com \
--to=johan.korsnes@gmail.com \
--cc=linux-media@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox