V4L/DVB (10167): sms1xxx: add support for inverted gpio

negative gpio values signify inverted polarity

Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Michael Krufky and committed by
Mauro Carvalho Chehab
dd72f31b e4cda3e0

+13 -4
+13 -4
drivers/media/dvb/siano/sms-cards.c
··· 131 131 return &sms_boards[id]; 132 132 } 133 133 134 - static int sms_set_gpio(struct smscore_device_t *coredev, u32 pin, int enable) 134 + static int sms_set_gpio(struct smscore_device_t *coredev, int pin, int enable) 135 135 { 136 - int ret; 136 + int lvl, ret; 137 + u32 gpio; 137 138 struct smscore_gpio_config gpioconfig = { 138 139 .direction = SMS_GPIO_DIRECTION_OUTPUT, 139 140 .pullupdown = SMS_GPIO_PULLUPDOWN_NONE, ··· 146 145 if (pin == 0) 147 146 return -EINVAL; 148 147 149 - ret = smscore_configure_gpio(coredev, pin, &gpioconfig); 148 + if (pin < 0) { 149 + /* inverted gpio */ 150 + gpio = pin * -1; 151 + lvl = enable ? 0 : 1; 152 + } else { 153 + gpio = pin; 154 + lvl = enable ? 1 : 0; 155 + } 150 156 157 + ret = smscore_configure_gpio(coredev, gpio, &gpioconfig); 151 158 if (ret < 0) 152 159 return ret; 153 160 154 - return smscore_set_gpio(coredev, pin, enable); 161 + return smscore_set_gpio(coredev, gpio, lvl); 155 162 } 156 163 157 164 int sms_board_setup(struct smscore_device_t *coredev)