Changeset 5998:fa7bf107cb7f in roaraudio


Ignore:
Timestamp:
02/24/14 23:27:06 (5 years ago)
Author:
phi
Branch:
default
Message:

first and most incomplet patch for SPI based transfers in the I2C DMX driver

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/driver_i2cdmx.c

    r5961 r5998  
    3131#include <linux/i2c-dev.h> 
    3232 
     33#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV 
     34#include <linux/spi/spidev.h> 
     35#include <sys/ioctl.h> 
     36 
     37#define TRANSFER_DELAY 5 
     38#define TRANSFER_SPEED 1000000 
     39#define TRANSFER_BPW   8 
     40#endif 
     41 
    3342#define DEFAULT_DEVICE  "/dev/i2c-1" 
    3443 
     
    6170struct driver_i2cdmx { 
    6271 struct roar_vio_calls vio; 
     72 struct roar_vio_calls spi; 
     73 int have_spi; 
    6374 uint8_t slave; 
    6475 size_t startaddr; 
    6576 size_t len; 
    6677}; 
     78 
     79static int __spi_transfer(struct driver_i2cdmx * self, void * txbuffer, void * rxbuffer, size_t len) { 
     80#ifdef ROAR_HAVE_H_LINUX_SPI_SPIDEV 
     81 struct spi_ioc_transfer transfer_buffer = { 
     82  .tx_buf = (unsigned long) txbuffer, 
     83  .rx_buf = (unsigned long) rxbuffer, 
     84  .len = len, 
     85  .delay_usecs = TRANSFER_DELAY, 
     86  .speed_hz = TRANSFER_SPEED, 
     87  .bits_per_word = TRANSFER_BPW, 
     88 }; 
     89 struct roar_vio_sysio_ioctl ctl = {.cmd = SPI_IOC_MESSAGE(1), .argp = &transfer_buffer}; 
     90 
     91 if ( roar_vio_ctl(self->spi, ROAR_VIO_CTL_SYSIO_IOCTL, &ctl) == -1 ) 
     92  return -1; 
     93 
     94 return 0; 
     95#else 
     96 roar_err_set(ROAR_ERROR_NOSYS); 
     97 return -1; 
     98#endif 
     99} 
    67100 
    68101static inline int __i2c_set_slave(struct driver_i2cdmx * self) { 
     
    341374 struct driver_i2cdmx * self = vio->inst; 
    342375 roar_vio_close(&(self->vio)); 
     376 if ( self->have_spi ) 
     377  roar_vio_close(&(self->spi)); 
    343378 roar_mm_free(self); 
    344379 return 0; 
     
    360395 } 
    361396 memset(self, 0, sizeof(*self)); 
     397 self->have_spi  = 0; 
    362398 self->startaddr = 0; 
    363399 self->len       = info->channels; 
Note: See TracChangeset for help on using the changeset viewer.