Lines Matching full:cec
15 #include <media/cec.h>
20 static void hdmirx_cec_write(struct hdmirx_cec *cec, int reg, u32 val) in hdmirx_cec_write() argument
22 cec->ops->write(cec->hdmirx, reg, val); in hdmirx_cec_write()
25 static u32 hdmirx_cec_read(struct hdmirx_cec *cec, int reg) in hdmirx_cec_read() argument
27 return cec->ops->read(cec->hdmirx, reg); in hdmirx_cec_read()
30 static void hdmirx_cec_update_bits(struct hdmirx_cec *cec, int reg, u32 mask, in hdmirx_cec_update_bits() argument
33 u32 val = hdmirx_cec_read(cec, reg) & ~mask; in hdmirx_cec_update_bits()
36 hdmirx_cec_write(cec, reg, val); in hdmirx_cec_update_bits()
41 struct hdmirx_cec *cec = cec_get_drvdata(adap); in hdmirx_cec_log_addr() local
44 cec->addresses = 0; in hdmirx_cec_log_addr()
46 cec->addresses |= BIT(logical_addr) | BIT(15); in hdmirx_cec_log_addr()
48 hdmirx_cec_write(cec, CEC_ADDR, cec->addresses); in hdmirx_cec_log_addr()
59 struct hdmirx_cec *cec = cec_get_drvdata(adap); in hdmirx_cec_transmit() local
65 hdmirx_cec_write(cec, CEC_TX_COUNT, msg_len - 1); in hdmirx_cec_transmit()
72 hdmirx_cec_write(cec, CEC_TX_DATA3_0 + i * 4, data[i]); in hdmirx_cec_transmit()
74 hdmirx_cec_write(cec, CEC_TX_CONTROL, 0x1); in hdmirx_cec_transmit()
82 struct hdmirx_cec *cec = cec_get_drvdata(adap); in hdmirx_cec_hardirq() local
83 u32 stat = hdmirx_cec_read(cec, CEC_INT_STATUS); in hdmirx_cec_hardirq()
90 hdmirx_cec_write(cec, CEC_INT_CLEAR, stat); in hdmirx_cec_hardirq()
93 cec->tx_status = CEC_TX_STATUS_ERROR; in hdmirx_cec_hardirq()
94 cec->tx_done = true; in hdmirx_cec_hardirq()
97 cec->tx_status = CEC_TX_STATUS_OK; in hdmirx_cec_hardirq()
98 cec->tx_done = true; in hdmirx_cec_hardirq()
101 cec->tx_status = CEC_TX_STATUS_NACK; in hdmirx_cec_hardirq()
102 cec->tx_done = true; in hdmirx_cec_hardirq()
105 cec->tx_status = CEC_TX_STATUS_ARB_LOST; in hdmirx_cec_hardirq()
106 cec->tx_done = true; in hdmirx_cec_hardirq()
113 val = hdmirx_cec_read(cec, CEC_RX_COUNT_STATUS); in hdmirx_cec_hardirq()
119 if (len > sizeof(cec->rx_msg.msg)) in hdmirx_cec_hardirq()
120 len = sizeof(cec->rx_msg.msg); in hdmirx_cec_hardirq()
124 val = hdmirx_cec_read(cec, CEC_RX_DATA3_0 + i / 4 * 4); in hdmirx_cec_hardirq()
125 cec->rx_msg.msg[i] = (val >> ((i % 4) * 8)) & 0xff; in hdmirx_cec_hardirq()
128 cec->rx_msg.len = len; in hdmirx_cec_hardirq()
130 cec->rx_done = true; in hdmirx_cec_hardirq()
131 hdmirx_cec_write(cec, CEC_LOCK_CONTROL, 0x1); in hdmirx_cec_hardirq()
142 struct hdmirx_cec *cec = cec_get_drvdata(adap); in hdmirx_cec_thread() local
144 if (cec->tx_done) { in hdmirx_cec_thread()
145 cec->tx_done = false; in hdmirx_cec_thread()
146 cec_transmit_attempt_done(adap, cec->tx_status); in hdmirx_cec_thread()
148 if (cec->rx_done) { in hdmirx_cec_thread()
149 cec->rx_done = false; in hdmirx_cec_thread()
151 cec_received_msg(adap, &cec->rx_msg); in hdmirx_cec_thread()
159 struct hdmirx_cec *cec = cec_get_drvdata(adap); in hdmirx_cec_enable() local
162 hdmirx_cec_write(cec, CEC_INT_MASK_N, 0); in hdmirx_cec_enable()
163 hdmirx_cec_write(cec, CEC_INT_CLEAR, 0); in hdmirx_cec_enable()
164 if (cec->ops->disable) in hdmirx_cec_enable()
165 cec->ops->disable(cec->hdmirx); in hdmirx_cec_enable()
169 hdmirx_cec_log_addr(cec->adap, CEC_LOG_ADDR_INVALID); in hdmirx_cec_enable()
170 if (cec->ops->enable) in hdmirx_cec_enable()
171 cec->ops->enable(cec->hdmirx); in hdmirx_cec_enable()
172 hdmirx_cec_update_bits(cec, GLOBAL_SWENABLE, CEC_ENABLE, CEC_ENABLE); in hdmirx_cec_enable()
175 hdmirx_cec_write(cec, CEC_INT_MASK_N, irqs); in hdmirx_cec_enable()
189 struct hdmirx_cec *cec = data; in hdmirx_cec_del() local
191 cec_delete_adapter(cec->adap); in hdmirx_cec_del()
196 struct hdmirx_cec *cec; in snps_hdmirx_cec_register() local
203 * between the HDMI hardware and its associated CEC chardev. in snps_hdmirx_cec_register()
205 cec = devm_kzalloc(data->dev, sizeof(*cec), GFP_KERNEL); in snps_hdmirx_cec_register()
206 if (!cec) in snps_hdmirx_cec_register()
209 cec->dev = data->dev; in snps_hdmirx_cec_register()
210 cec->irq = data->irq; in snps_hdmirx_cec_register()
211 cec->ops = data->ops; in snps_hdmirx_cec_register()
212 cec->hdmirx = data->hdmirx; in snps_hdmirx_cec_register()
214 hdmirx_cec_update_bits(cec, GLOBAL_SWENABLE, CEC_ENABLE, CEC_ENABLE); in snps_hdmirx_cec_register()
215 hdmirx_cec_update_bits(cec, CEC_CONFIG, RX_AUTO_DRIVE_ACKNOWLEDGE, in snps_hdmirx_cec_register()
218 hdmirx_cec_write(cec, CEC_TX_COUNT, 0); in snps_hdmirx_cec_register()
219 hdmirx_cec_write(cec, CEC_INT_MASK_N, 0); in snps_hdmirx_cec_register()
220 hdmirx_cec_write(cec, CEC_INT_CLEAR, ~0); in snps_hdmirx_cec_register()
222 cec->adap = cec_allocate_adapter(&hdmirx_cec_ops, cec, "snps-hdmirx", in snps_hdmirx_cec_register()
225 if (IS_ERR(cec->adap)) { in snps_hdmirx_cec_register()
226 dev_err(cec->dev, "cec adapter allocation failed\n"); in snps_hdmirx_cec_register()
227 return ERR_CAST(cec->adap); in snps_hdmirx_cec_register()
231 cec->adap->owner = THIS_MODULE; in snps_hdmirx_cec_register()
233 ret = devm_add_action(cec->dev, hdmirx_cec_del, cec); in snps_hdmirx_cec_register()
235 cec_delete_adapter(cec->adap); in snps_hdmirx_cec_register()
239 irq_set_status_flags(cec->irq, IRQ_NOAUTOEN); in snps_hdmirx_cec_register()
241 ret = devm_request_threaded_irq(cec->dev, cec->irq, in snps_hdmirx_cec_register()
244 "rk_hdmirx_cec", cec->adap); in snps_hdmirx_cec_register()
246 dev_err(cec->dev, "cec irq request failed\n"); in snps_hdmirx_cec_register()
250 ret = cec_register_adapter(cec->adap, cec->dev); in snps_hdmirx_cec_register()
252 dev_err(cec->dev, "cec adapter registration failed\n"); in snps_hdmirx_cec_register()
257 hdmirx_cec_write(cec, CEC_INT_MASK_N, irqs); in snps_hdmirx_cec_register()
260 * CEC documentation says we must not call cec_delete_adapter in snps_hdmirx_cec_register()
263 devm_remove_action(cec->dev, hdmirx_cec_del, cec); in snps_hdmirx_cec_register()
265 enable_irq(cec->irq); in snps_hdmirx_cec_register()
267 return cec; in snps_hdmirx_cec_register()
270 void snps_hdmirx_cec_unregister(struct hdmirx_cec *cec) in snps_hdmirx_cec_unregister() argument
272 disable_irq(cec->irq); in snps_hdmirx_cec_unregister()
274 cec_unregister_adapter(cec->adap); in snps_hdmirx_cec_unregister()