Lines Matching +full:out +full:- +full:functions
1 // SPDX-License-Identifier: GPL-2.0
4 #include <media/drv-intf/saa7146_vv.h>
8 /* DEB_I2C("'%s'\n", adapter->name); */ in saa7146_i2c_func()
16 /* this function returns the status-register of our i2c-device */
24 /* this function runs through the i2c-messages and prepares the data to be
26 to understand this. it returns the number of u32s to send, or -1
41 mem = 1 + ((mem-1) / 3); in saa7146_i2c_msg_prepare()
47 /* DEB_I2C("cannot prepare i2c-message\n"); */ in saa7146_i2c_msg_prepare()
48 return -ENOMEM; in saa7146_i2c_msg_prepare()
51 /* be careful: clear out the i2c-mem first */ in saa7146_i2c_msg_prepare()
59 op[h1] |= cpu_to_le32( (u8)addr << ((3-h2)*8)); in saa7146_i2c_msg_prepare()
60 op[h1] |= cpu_to_le32(SAA7146_I2C_START << ((3-h2)*2)); in saa7146_i2c_msg_prepare()
67 op[h1] |= cpu_to_le32( (u32)((u8)m[i].buf[j]) << ((3-h2)*8)); in saa7146_i2c_msg_prepare()
68 op[h1] |= cpu_to_le32( SAA7146_I2C_CONT << ((3-h2)*2)); in saa7146_i2c_msg_prepare()
76 h1 = (op_count-1)/3; h2 = (op_count-1)%3; in saa7146_i2c_msg_prepare()
77 if ( SAA7146_I2C_CONT == (0x3 & (le32_to_cpu(op[h1]) >> ((3-h2)*2))) ) { in saa7146_i2c_msg_prepare()
78 op[h1] &= ~cpu_to_le32(0x2 << ((3-h2)*2)); in saa7146_i2c_msg_prepare()
79 op[h1] |= cpu_to_le32(SAA7146_I2C_STOP << ((3-h2)*2)); in saa7146_i2c_msg_prepare()
86 /* this functions loops through all i2c-messages. normally, it should determine
88 i2c-message. but instead, we simply write back all bytes.
103 m[i].buf[j] = (le32_to_cpu(op[op_count/3]) >> ((3-(op_count%3))*8)); in saa7146_i2c_msg_cleanup()
111 /* this functions resets the i2c-device and returns 0 if everything was fine, otherwise -1 */
118 saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); in saa7146_i2c_reset()
127 /* set "ABORT-OPERATION"-bit (bit 7)*/ in saa7146_i2c_reset()
128 saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07)); in saa7146_i2c_reset()
132 /* clear all error-bits pending; this is needed because p.123, note 1 */ in saa7146_i2c_reset()
133 saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); in saa7146_i2c_reset()
141 if ( dev->i2c_bitrate != status ) { in saa7146_i2c_reset()
147 saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07)); in saa7146_i2c_reset()
151 /* clear all error-bits pending */ in saa7146_i2c_reset()
152 saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); in saa7146_i2c_reset()
158 saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); in saa7146_i2c_reset()
165 if ( dev->i2c_bitrate != status ) { in saa7146_i2c_reset()
167 return -1; in saa7146_i2c_reset()
173 /* this functions writes out the data-byte 'dword' to the i2c-device.
174 it returns 0 if ok, -1 if the transfer failed, -2 if the transfer
182 /* write out i2c-command */ in saa7146_i2c_writeout()
184 *dword, saa7146_read(dev, I2C_STATUS), dev->i2c_op); in saa7146_i2c_writeout()
186 if( 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) { in saa7146_i2c_writeout()
188 saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); in saa7146_i2c_writeout()
191 dev->i2c_op = 1; in saa7146_i2c_writeout()
197 timeout = wait_event_interruptible_timeout(dev->i2c_wq, dev->i2c_op == 0, timeout); in saa7146_i2c_writeout()
198 if (timeout == -ERESTARTSYS || dev->i2c_op) { in saa7146_i2c_writeout()
201 if (timeout == -ERESTARTSYS) in saa7146_i2c_writeout()
203 return -ERESTARTSYS; in saa7146_i2c_writeout()
205 pr_warn("%s %s [irq]: timed out waiting for end of xfer\n", in saa7146_i2c_writeout()
206 dev->name, __func__); in saa7146_i2c_writeout()
207 return -EIO; in saa7146_i2c_writeout()
211 saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); in saa7146_i2c_writeout()
215 /* do not poll for i2c-status before upload is complete */ in saa7146_i2c_writeout()
223 pr_warn("%s %s: timed out waiting for MC2\n", in saa7146_i2c_writeout()
224 dev->name, __func__); in saa7146_i2c_writeout()
225 return -EIO; in saa7146_i2c_writeout()
240 pr_warn("%s %s [poll]: timed out waiting for end of xfer\n", in saa7146_i2c_writeout()
241 dev->name, __func__); in saa7146_i2c_writeout()
242 return -EIO; in saa7146_i2c_writeout()
259 /* it may take some time until ERR goes high - ignore */ in saa7146_i2c_writeout()
275 /* we handle address-errors here */ in saa7146_i2c_writeout()
278 return -EREMOTEIO; in saa7146_i2c_writeout()
281 return -EIO; in saa7146_i2c_writeout()
294 __le32 *buffer = dev->d_i2c.cpu_addr; in saa7146_i2c_transfer()
298 if (mutex_lock_interruptible(&dev->i2c_lock)) in saa7146_i2c_transfer()
299 return -ERESTARTSYS; in saa7146_i2c_transfer()
308 err = -EIO; in saa7146_i2c_transfer()
309 goto out; in saa7146_i2c_transfer()
312 if ( count > 3 || 0 != (SAA7146_I2C_SHORT_DELAY & dev->ext->flags) ) in saa7146_i2c_transfer()
316 /* reset the i2c-device if necessary */ in saa7146_i2c_transfer()
319 DEB_I2C("could not reset i2c-device\n"); in saa7146_i2c_transfer()
320 goto out; in saa7146_i2c_transfer()
323 /* write out the u32s one after another */ in saa7146_i2c_transfer()
335 it should be avoided. So we bail out in irq mode after an in saa7146_i2c_transfer()
337 if (-EREMOTEIO == err && 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) in saa7146_i2c_transfer()
338 goto out; in saa7146_i2c_transfer()
351 } while (err != num && retries--); in saa7146_i2c_transfer()
355 goto out; in saa7146_i2c_transfer()
359 DEB_I2C("could not cleanup i2c-message\n"); in saa7146_i2c_transfer()
360 err = -EIO; in saa7146_i2c_transfer()
361 goto out; in saa7146_i2c_transfer()
366 out: in saa7146_i2c_transfer()
367 /* another bug in revision 0: the i2c-registers get uploaded randomly by other in saa7146_i2c_transfer()
368 uploads, so we better clear them out before continuing */ in saa7146_i2c_transfer()
369 if( 0 == dev->revision ) { in saa7146_i2c_transfer()
377 mutex_unlock(&dev->i2c_lock); in saa7146_i2c_transfer()
381 /* utility functions */
388 return saa7146_i2c_transfer(dev, msg, num, adapter->retries); in saa7146_i2c_xfer()
393 /* i2c-adapter helper functions */
405 /* enable i2c-port pins */ in saa7146_i2c_adapter_prepare()
408 dev->i2c_bitrate = bitrate; in saa7146_i2c_adapter_prepare()
412 i2c_set_adapdata(i2c_adapter, &dev->v4l2_dev); in saa7146_i2c_adapter_prepare()
413 i2c_adapter->dev.parent = &dev->pci->dev; in saa7146_i2c_adapter_prepare()
414 i2c_adapter->algo = &saa7146_algo; in saa7146_i2c_adapter_prepare()
415 i2c_adapter->algo_data = NULL; in saa7146_i2c_adapter_prepare()
416 i2c_adapter->timeout = SAA7146_I2C_TIMEOUT; in saa7146_i2c_adapter_prepare()
417 i2c_adapter->retries = SAA7146_I2C_RETRIES; in saa7146_i2c_adapter_prepare()