Lines Matching full:cec
17 #include <media/cec.h>
18 #include <media/cec-notifier.h>
20 #include "dw-hdmi-qp-cec.h"
65 static void dw_hdmi_qp_write(struct dw_hdmi_qp_cec *cec, u32 val, int offset) in dw_hdmi_qp_write() argument
67 cec->ops->write(cec->hdmi, val, offset); in dw_hdmi_qp_write()
70 static u32 dw_hdmi_qp_read(struct dw_hdmi_qp_cec *cec, int offset) in dw_hdmi_qp_read() argument
72 return cec->ops->read(cec->hdmi, offset); in dw_hdmi_qp_read()
77 struct dw_hdmi_qp_cec *cec = cec_get_drvdata(adap); in dw_hdmi_qp_cec_log_addr() local
80 cec->addresses = 0; in dw_hdmi_qp_cec_log_addr()
82 cec->addresses |= BIT(logical_addr) | BIT(15); in dw_hdmi_qp_cec_log_addr()
84 dw_hdmi_qp_write(cec, cec->addresses, CEC_ADDR); in dw_hdmi_qp_cec_log_addr()
92 struct dw_hdmi_qp_cec *cec = cec_get_drvdata(adap); in dw_hdmi_qp_cec_transmit() local
107 dw_hdmi_qp_write(cec, val, CEC_TX_DATA3_0 + (i / 4) * 4); in dw_hdmi_qp_cec_transmit()
110 dw_hdmi_qp_write(cec, msg->len - 1, CEC_TX_CNT); in dw_hdmi_qp_cec_transmit()
111 dw_hdmi_qp_write(cec, CEC_CTRL_START, CEC_TX_CONTROL); in dw_hdmi_qp_cec_transmit()
119 struct dw_hdmi_qp_cec *cec = cec_get_drvdata(adap); in dw_hdmi_qp_cec_hardirq() local
120 u32 stat = dw_hdmi_qp_read(cec, CEC_INT_STATUS); in dw_hdmi_qp_cec_hardirq()
126 dw_hdmi_qp_write(cec, stat, CEC_INT_CLEAR); in dw_hdmi_qp_cec_hardirq()
129 cec->tx_status = CEC_TX_STATUS_ERROR; in dw_hdmi_qp_cec_hardirq()
130 cec->tx_done = true; in dw_hdmi_qp_cec_hardirq()
133 cec->tx_status = CEC_TX_STATUS_OK; in dw_hdmi_qp_cec_hardirq()
134 cec->tx_done = true; in dw_hdmi_qp_cec_hardirq()
137 cec->tx_status = CEC_TX_STATUS_NACK; in dw_hdmi_qp_cec_hardirq()
138 cec->tx_done = true; in dw_hdmi_qp_cec_hardirq()
145 val = dw_hdmi_qp_read(cec, CEC_RX_CNT); in dw_hdmi_qp_cec_hardirq()
148 if (len > sizeof(cec->rx_msg.msg)) in dw_hdmi_qp_cec_hardirq()
149 len = sizeof(cec->rx_msg.msg); in dw_hdmi_qp_cec_hardirq()
152 val = dw_hdmi_qp_read(cec, CEC_RX_DATA3_0 + i * 4); in dw_hdmi_qp_cec_hardirq()
153 cec->rx_msg.msg[i * 4] = val & 0xff; in dw_hdmi_qp_cec_hardirq()
154 cec->rx_msg.msg[i * 4 + 1] = (val >> 8) & 0xff; in dw_hdmi_qp_cec_hardirq()
155 cec->rx_msg.msg[i * 4 + 2] = (val >> 16) & 0xff; in dw_hdmi_qp_cec_hardirq()
156 cec->rx_msg.msg[i * 4 + 3] = (val >> 24) & 0xff; in dw_hdmi_qp_cec_hardirq()
159 dw_hdmi_qp_write(cec, 1, CEC_LOCK_CONTROL); in dw_hdmi_qp_cec_hardirq()
161 cec->rx_msg.len = len; in dw_hdmi_qp_cec_hardirq()
162 cec->rx_done = true; in dw_hdmi_qp_cec_hardirq()
173 struct dw_hdmi_qp_cec *cec = cec_get_drvdata(adap); in dw_hdmi_qp_cec_thread() local
175 if (cec->tx_done) { in dw_hdmi_qp_cec_thread()
176 cec->tx_done = false; in dw_hdmi_qp_cec_thread()
177 cec_transmit_attempt_done(adap, cec->tx_status); in dw_hdmi_qp_cec_thread()
179 if (cec->rx_done) { in dw_hdmi_qp_cec_thread()
180 cec->rx_done = false; in dw_hdmi_qp_cec_thread()
181 cec_received_msg(adap, &cec->rx_msg); in dw_hdmi_qp_cec_thread()
188 struct dw_hdmi_qp_cec *cec = cec_get_drvdata(adap); in dw_hdmi_qp_cec_enable() local
191 dw_hdmi_qp_write(cec, 0, CEC_INT_MASK_N); in dw_hdmi_qp_cec_enable()
192 dw_hdmi_qp_write(cec, ~0, CEC_INT_CLEAR); in dw_hdmi_qp_cec_enable()
193 cec->ops->disable(cec->hdmi); in dw_hdmi_qp_cec_enable()
197 cec->ops->enable(cec->hdmi); in dw_hdmi_qp_cec_enable()
199 dw_hdmi_qp_write(cec, ~0, CEC_INT_CLEAR); in dw_hdmi_qp_cec_enable()
200 dw_hdmi_qp_write(cec, 1, CEC_LOCK_CONTROL); in dw_hdmi_qp_cec_enable()
202 dw_hdmi_qp_cec_log_addr(cec->adap, CEC_LOG_ADDR_INVALID); in dw_hdmi_qp_cec_enable()
206 dw_hdmi_qp_write(cec, ~0, CEC_INT_CLEAR); in dw_hdmi_qp_cec_enable()
207 dw_hdmi_qp_write(cec, irqs, CEC_INT_MASK_N); in dw_hdmi_qp_cec_enable()
220 struct dw_hdmi_qp_cec *cec = data; in dw_hdmi_qp_cec_del() local
222 cec_delete_adapter(cec->adap); in dw_hdmi_qp_cec_del()
228 struct dw_hdmi_qp_cec *cec; in dw_hdmi_qp_cec_probe() local
239 * between the HDMI hardware and its associated CEC chardev. in dw_hdmi_qp_cec_probe()
241 cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL); in dw_hdmi_qp_cec_probe()
242 if (!cec) in dw_hdmi_qp_cec_probe()
245 cec->ops = data->ops; in dw_hdmi_qp_cec_probe()
246 cec->hdmi = data->hdmi; in dw_hdmi_qp_cec_probe()
247 cec->irq = data->irq; in dw_hdmi_qp_cec_probe()
249 platform_set_drvdata(pdev, cec); in dw_hdmi_qp_cec_probe()
251 dw_hdmi_qp_write(cec, 0, CEC_TX_CNT); in dw_hdmi_qp_cec_probe()
252 dw_hdmi_qp_write(cec, ~0, CEC_INT_CLEAR); in dw_hdmi_qp_cec_probe()
253 dw_hdmi_qp_write(cec, 0, CEC_INT_MASK_N); in dw_hdmi_qp_cec_probe()
255 cec->adap = cec_allocate_adapter(&dw_hdmi_qp_cec_ops, cec, "dw_hdmi_qp", in dw_hdmi_qp_cec_probe()
259 if (IS_ERR(cec->adap)) { in dw_hdmi_qp_cec_probe()
260 dev_err(&pdev->dev, "cec allocate adapter failed\n"); in dw_hdmi_qp_cec_probe()
261 return PTR_ERR(cec->adap); in dw_hdmi_qp_cec_probe()
264 dw_hdmi_qp_set_cec_adap(cec->hdmi, cec->adap); in dw_hdmi_qp_cec_probe()
267 cec->adap->owner = THIS_MODULE; in dw_hdmi_qp_cec_probe()
269 ret = devm_add_action(&pdev->dev, dw_hdmi_qp_cec_del, cec); in dw_hdmi_qp_cec_probe()
271 dev_err(&pdev->dev, "cec add action failed\n"); in dw_hdmi_qp_cec_probe()
272 cec_delete_adapter(cec->adap); in dw_hdmi_qp_cec_probe()
276 if (cec->irq < 0) { in dw_hdmi_qp_cec_probe()
277 ret = cec->irq; in dw_hdmi_qp_cec_probe()
278 dev_err(&pdev->dev, "cec get irq failed\n"); in dw_hdmi_qp_cec_probe()
282 ret = devm_request_threaded_irq(&pdev->dev, cec->irq, in dw_hdmi_qp_cec_probe()
285 "dw-hdmi-qp-cec", cec->adap); in dw_hdmi_qp_cec_probe()
287 dev_err(&pdev->dev, "cec request irq thread failed\n"); in dw_hdmi_qp_cec_probe()
291 cec->notify = cec_notifier_cec_adap_register(pdev->dev.parent, in dw_hdmi_qp_cec_probe()
292 NULL, cec->adap); in dw_hdmi_qp_cec_probe()
293 if (!cec->notify) { in dw_hdmi_qp_cec_probe()
294 dev_err(&pdev->dev, "cec notifier adap register failed\n"); in dw_hdmi_qp_cec_probe()
298 ret = cec_register_adapter(cec->adap, pdev->dev.parent); in dw_hdmi_qp_cec_probe()
300 dev_err(&pdev->dev, "cec adap register failed\n"); in dw_hdmi_qp_cec_probe()
301 cec_notifier_cec_adap_unregister(cec->notify, cec->adap); in dw_hdmi_qp_cec_probe()
306 * CEC documentation says we must not call cec_delete_adapter in dw_hdmi_qp_cec_probe()
309 devm_remove_action(&pdev->dev, dw_hdmi_qp_cec_del, cec); in dw_hdmi_qp_cec_probe()
316 struct dw_hdmi_qp_cec *cec = platform_get_drvdata(pdev); in dw_hdmi_qp_cec_remove() local
318 cec_notifier_cec_adap_unregister(cec->notify, cec->adap); in dw_hdmi_qp_cec_remove()
319 cec_unregister_adapter(cec->adap); in dw_hdmi_qp_cec_remove()
328 .name = "dw-hdmi-qp-cec",
334 MODULE_DESCRIPTION("Synopsys Designware HDMI QP CEC driver");
336 MODULE_ALIAS(PLATFORM_MODULE_PREFIX "dw-hdmi-qp-cec");