Version:  2.0.40 2.2.26 2.4.37 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16

Linux/drivers/staging/media/solo6x10/solo6x10-core.c

  1 /*
  2  * Copyright (C) 2010-2013 Bluecherry, LLC <http://www.bluecherrydvr.com>
  3  *
  4  * Original author:
  5  * Ben Collins <bcollins@ubuntu.com>
  6  *
  7  * Additional work by:
  8  * John Brooks <john.brooks@bluecherry.net>
  9  *
 10  * This program is free software; you can redistribute it and/or modify
 11  * it under the terms of the GNU General Public License as published by
 12  * the Free Software Foundation; either version 2 of the License, or
 13  * (at your option) any later version.
 14  *
 15  * This program is distributed in the hope that it will be useful,
 16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 18  * GNU General Public License for more details.
 19  *
 20  * You should have received a copy of the GNU General Public License
 21  * along with this program; if not, write to the Free Software
 22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 23  */
 24 
 25 #include <linux/kernel.h>
 26 #include <linux/module.h>
 27 #include <linux/pci.h>
 28 #include <linux/interrupt.h>
 29 #include <linux/videodev2.h>
 30 #include <linux/delay.h>
 31 #include <linux/sysfs.h>
 32 #include <linux/ktime.h>
 33 #include <linux/slab.h>
 34 
 35 #include "solo6x10.h"
 36 #include "solo6x10-tw28.h"
 37 
 38 MODULE_DESCRIPTION("Softlogic 6x10 MPEG4/H.264/G.723 CODEC V4L2/ALSA Driver");
 39 MODULE_AUTHOR("Bluecherry <maintainers@bluecherrydvr.com>");
 40 MODULE_VERSION(SOLO6X10_VERSION);
 41 MODULE_LICENSE("GPL");
 42 
 43 static unsigned video_nr = -1;
 44 module_param(video_nr, uint, 0644);
 45 MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect (default)");
 46 
 47 static int full_eeprom; /* default is only top 64B */
 48 module_param(full_eeprom, uint, 0644);
 49 MODULE_PARM_DESC(full_eeprom, "Allow access to full 128B EEPROM (dangerous)");
 50 
 51 
 52 static void solo_set_time(struct solo_dev *solo_dev)
 53 {
 54         struct timespec ts;
 55 
 56         ktime_get_ts(&ts);
 57 
 58         solo_reg_write(solo_dev, SOLO_TIMER_SEC, ts.tv_sec);
 59         solo_reg_write(solo_dev, SOLO_TIMER_USEC, ts.tv_nsec / NSEC_PER_USEC);
 60 }
 61 
 62 static void solo_timer_sync(struct solo_dev *solo_dev)
 63 {
 64         u32 sec, usec;
 65         struct timespec ts;
 66         long diff;
 67 
 68         if (solo_dev->type != SOLO_DEV_6110)
 69                 return;
 70 
 71         if (++solo_dev->time_sync < 60)
 72                 return;
 73 
 74         solo_dev->time_sync = 0;
 75 
 76         sec = solo_reg_read(solo_dev, SOLO_TIMER_SEC);
 77         usec = solo_reg_read(solo_dev, SOLO_TIMER_USEC);
 78 
 79         ktime_get_ts(&ts);
 80 
 81         diff = (long)ts.tv_sec - (long)sec;
 82         diff = (diff * 1000000)
 83                 + ((long)(ts.tv_nsec / NSEC_PER_USEC) - (long)usec);
 84 
 85         if (diff > 1000 || diff < -1000) {
 86                 solo_set_time(solo_dev);
 87         } else if (diff) {
 88                 long usec_lsb = solo_dev->usec_lsb;
 89 
 90                 usec_lsb -= diff / 4;
 91                 if (usec_lsb < 0)
 92                         usec_lsb = 0;
 93                 else if (usec_lsb > 255)
 94                         usec_lsb = 255;
 95 
 96                 solo_dev->usec_lsb = usec_lsb;
 97                 solo_reg_write(solo_dev, SOLO_TIMER_USEC_LSB,
 98                                solo_dev->usec_lsb);
 99         }
100 }
101 
102 static irqreturn_t solo_isr(int irq, void *data)
103 {
104         struct solo_dev *solo_dev = data;
105         u32 status;
106         int i;
107 
108         status = solo_reg_read(solo_dev, SOLO_IRQ_STAT);
109         if (!status)
110                 return IRQ_NONE;
111 
112         if (status & ~solo_dev->irq_mask) {
113                 solo_reg_write(solo_dev, SOLO_IRQ_STAT,
114                                status & ~solo_dev->irq_mask);
115                 status &= solo_dev->irq_mask;
116         }
117 
118         if (status & SOLO_IRQ_PCI_ERR)
119                 solo_p2m_error_isr(solo_dev);
120 
121         for (i = 0; i < SOLO_NR_P2M; i++)
122                 if (status & SOLO_IRQ_P2M(i))
123                         solo_p2m_isr(solo_dev, i);
124 
125         if (status & SOLO_IRQ_IIC)
126                 solo_i2c_isr(solo_dev);
127 
128         if (status & SOLO_IRQ_VIDEO_IN) {
129                 solo_video_in_isr(solo_dev);
130                 solo_timer_sync(solo_dev);
131         }
132 
133         if (status & SOLO_IRQ_ENCODER)
134                 solo_enc_v4l2_isr(solo_dev);
135 
136         if (status & SOLO_IRQ_G723)
137                 solo_g723_isr(solo_dev);
138 
139         /* Clear all interrupts handled */
140         solo_reg_write(solo_dev, SOLO_IRQ_STAT, status);
141 
142         return IRQ_HANDLED;
143 }
144 
145 static void free_solo_dev(struct solo_dev *solo_dev)
146 {
147         struct pci_dev *pdev;
148 
149         if (!solo_dev)
150                 return;
151 
152         if (solo_dev->dev.parent)
153                 device_unregister(&solo_dev->dev);
154 
155         pdev = solo_dev->pdev;
156 
157         /* If we never initialized the PCI device, then nothing else
158          * below here needs cleanup */
159         if (!pdev) {
160                 kfree(solo_dev);
161                 return;
162         }
163 
164         if (solo_dev->reg_base) {
165                 /* Bring down the sub-devices first */
166                 solo_g723_exit(solo_dev);
167                 solo_enc_v4l2_exit(solo_dev);
168                 solo_enc_exit(solo_dev);
169                 solo_v4l2_exit(solo_dev);
170                 solo_disp_exit(solo_dev);
171                 solo_gpio_exit(solo_dev);
172                 solo_p2m_exit(solo_dev);
173                 solo_i2c_exit(solo_dev);
174 
175                 /* Now cleanup the PCI device */
176                 solo_irq_off(solo_dev, ~0);
177                 pci_iounmap(pdev, solo_dev->reg_base);
178                 if (pdev->irq)
179                         free_irq(pdev->irq, solo_dev);
180         }
181 
182         pci_release_regions(pdev);
183         pci_disable_device(pdev);
184         v4l2_device_unregister(&solo_dev->v4l2_dev);
185         pci_set_drvdata(pdev, NULL);
186 
187         kfree(solo_dev);
188 }
189 
190 static ssize_t eeprom_store(struct device *dev, struct device_attribute *attr,
191                             const char *buf, size_t count)
192 {
193         struct solo_dev *solo_dev =
194                 container_of(dev, struct solo_dev, dev);
195         unsigned short *p = (unsigned short *)buf;
196         int i;
197 
198         if (count & 0x1)
199                 dev_warn(dev, "EEPROM Write not aligned (truncating)\n");
200 
201         if (!full_eeprom && count > 64) {
202                 dev_warn(dev, "EEPROM Write truncated to 64 bytes\n");
203                 count = 64;
204         } else if (full_eeprom && count > 128) {
205                 dev_warn(dev, "EEPROM Write truncated to 128 bytes\n");
206                 count = 128;
207         }
208 
209         solo_eeprom_ewen(solo_dev, 1);
210 
211         for (i = full_eeprom ? 0 : 32; i < min((int)(full_eeprom ? 64 : 32),
212                                                (int)(count / 2)); i++)
213                 solo_eeprom_write(solo_dev, i, cpu_to_be16(p[i]));
214 
215         solo_eeprom_ewen(solo_dev, 0);
216 
217         return count;
218 }
219 
220 static ssize_t eeprom_show(struct device *dev, struct device_attribute *attr,
221                            char *buf)
222 {
223         struct solo_dev *solo_dev =
224                 container_of(dev, struct solo_dev, dev);
225         unsigned short *p = (unsigned short *)buf;
226         int count = (full_eeprom ? 128 : 64);
227         int i;
228 
229         for (i = (full_eeprom ? 0 : 32); i < (count / 2); i++)
230                 p[i] = be16_to_cpu(solo_eeprom_read(solo_dev, i));
231 
232         return count;
233 }
234 
235 static ssize_t p2m_timeouts_show(struct device *dev,
236                                  struct device_attribute *attr,
237                                  char *buf)
238 {
239         struct solo_dev *solo_dev =
240                 container_of(dev, struct solo_dev, dev);
241 
242         return sprintf(buf, "%d\n", solo_dev->p2m_timeouts);
243 }
244 
245 static ssize_t sdram_size_show(struct device *dev,
246                                struct device_attribute *attr,
247                                char *buf)
248 {
249         struct solo_dev *solo_dev =
250                 container_of(dev, struct solo_dev, dev);
251 
252         return sprintf(buf, "%dMegs\n", solo_dev->sdram_size >> 20);
253 }
254 
255 static ssize_t tw28xx_show(struct device *dev,
256                            struct device_attribute *attr,
257                            char *buf)
258 {
259         struct solo_dev *solo_dev =
260                 container_of(dev, struct solo_dev, dev);
261 
262         return sprintf(buf, "tw2815[%d] tw2864[%d] tw2865[%d]\n",
263                        hweight32(solo_dev->tw2815),
264                        hweight32(solo_dev->tw2864),
265                        hweight32(solo_dev->tw2865));
266 }
267 
268 static ssize_t input_map_show(struct device *dev,
269                               struct device_attribute *attr,
270                               char *buf)
271 {
272         struct solo_dev *solo_dev =
273                 container_of(dev, struct solo_dev, dev);
274         unsigned int val;
275         char *out = buf;
276 
277         val = solo_reg_read(solo_dev, SOLO_VI_CH_SWITCH_0);
278         out += sprintf(out, "Channel 0   => Input %d\n", val & 0x1f);
279         out += sprintf(out, "Channel 1   => Input %d\n", (val >> 5) & 0x1f);
280         out += sprintf(out, "Channel 2   => Input %d\n", (val >> 10) & 0x1f);
281         out += sprintf(out, "Channel 3   => Input %d\n", (val >> 15) & 0x1f);
282         out += sprintf(out, "Channel 4   => Input %d\n", (val >> 20) & 0x1f);
283         out += sprintf(out, "Channel 5   => Input %d\n", (val >> 25) & 0x1f);
284 
285         val = solo_reg_read(solo_dev, SOLO_VI_CH_SWITCH_1);
286         out += sprintf(out, "Channel 6   => Input %d\n", val & 0x1f);
287         out += sprintf(out, "Channel 7   => Input %d\n", (val >> 5) & 0x1f);
288         out += sprintf(out, "Channel 8   => Input %d\n", (val >> 10) & 0x1f);
289         out += sprintf(out, "Channel 9   => Input %d\n", (val >> 15) & 0x1f);
290         out += sprintf(out, "Channel 10  => Input %d\n", (val >> 20) & 0x1f);
291         out += sprintf(out, "Channel 11  => Input %d\n", (val >> 25) & 0x1f);
292 
293         val = solo_reg_read(solo_dev, SOLO_VI_CH_SWITCH_2);
294         out += sprintf(out, "Channel 12  => Input %d\n", val & 0x1f);
295         out += sprintf(out, "Channel 13  => Input %d\n", (val >> 5) & 0x1f);
296         out += sprintf(out, "Channel 14  => Input %d\n", (val >> 10) & 0x1f);
297         out += sprintf(out, "Channel 15  => Input %d\n", (val >> 15) & 0x1f);
298         out += sprintf(out, "Spot Output => Input %d\n", (val >> 20) & 0x1f);
299 
300         return out - buf;
301 }
302 
303 static ssize_t p2m_timeout_store(struct device *dev,
304                                  struct device_attribute *attr,
305                                  const char *buf, size_t count)
306 {
307         struct solo_dev *solo_dev =
308                 container_of(dev, struct solo_dev, dev);
309         unsigned long ms;
310 
311         int ret = kstrtoul(buf, 10, &ms);
312         if (ret < 0 || ms > 200)
313                 return -EINVAL;
314         solo_dev->p2m_jiffies = msecs_to_jiffies(ms);
315 
316         return count;
317 }
318 
319 static ssize_t p2m_timeout_show(struct device *dev,
320                                 struct device_attribute *attr,
321                                 char *buf)
322 {
323         struct solo_dev *solo_dev =
324                 container_of(dev, struct solo_dev, dev);
325 
326         return sprintf(buf, "%ums\n", jiffies_to_msecs(solo_dev->p2m_jiffies));
327 }
328 
329 static ssize_t intervals_show(struct device *dev,
330                               struct device_attribute *attr,
331                               char *buf)
332 {
333         struct solo_dev *solo_dev =
334                 container_of(dev, struct solo_dev, dev);
335         char *out = buf;
336         int fps = solo_dev->fps;
337         int i;
338 
339         for (i = 0; i < solo_dev->nr_chans; i++) {
340                 out += sprintf(out, "Channel %d: %d/%d (0x%08x)\n",
341                                i, solo_dev->v4l2_enc[i]->interval, fps,
342                                solo_reg_read(solo_dev, SOLO_CAP_CH_INTV(i)));
343         }
344 
345         return out - buf;
346 }
347 
348 static ssize_t sdram_offsets_show(struct device *dev,
349                                   struct device_attribute *attr,
350                                   char *buf)
351 {
352         struct solo_dev *solo_dev =
353                 container_of(dev, struct solo_dev, dev);
354         char *out = buf;
355 
356         out += sprintf(out, "DISP: 0x%08x @ 0x%08x\n",
357                        SOLO_DISP_EXT_ADDR,
358                        SOLO_DISP_EXT_SIZE);
359 
360         out += sprintf(out, "EOSD: 0x%08x @ 0x%08x (0x%08x * %d)\n",
361                        SOLO_EOSD_EXT_ADDR,
362                        SOLO_EOSD_EXT_AREA(solo_dev),
363                        SOLO_EOSD_EXT_SIZE(solo_dev),
364                        SOLO_EOSD_EXT_AREA(solo_dev) /
365                        SOLO_EOSD_EXT_SIZE(solo_dev));
366 
367         out += sprintf(out, "MOTI: 0x%08x @ 0x%08x\n",
368                        SOLO_MOTION_EXT_ADDR(solo_dev),
369                        SOLO_MOTION_EXT_SIZE);
370 
371         out += sprintf(out, "G723: 0x%08x @ 0x%08x\n",
372                        SOLO_G723_EXT_ADDR(solo_dev),
373                        SOLO_G723_EXT_SIZE);
374 
375         out += sprintf(out, "CAPT: 0x%08x @ 0x%08x (0x%08x * %d)\n",
376                        SOLO_CAP_EXT_ADDR(solo_dev),
377                        SOLO_CAP_EXT_SIZE(solo_dev),
378                        SOLO_CAP_PAGE_SIZE,
379                        SOLO_CAP_EXT_SIZE(solo_dev) / SOLO_CAP_PAGE_SIZE);
380 
381         out += sprintf(out, "EREF: 0x%08x @ 0x%08x (0x%08x * %d)\n",
382                        SOLO_EREF_EXT_ADDR(solo_dev),
383                        SOLO_EREF_EXT_AREA(solo_dev),
384                        SOLO_EREF_EXT_SIZE,
385                        SOLO_EREF_EXT_AREA(solo_dev) / SOLO_EREF_EXT_SIZE);
386 
387         out += sprintf(out, "MPEG: 0x%08x @ 0x%08x\n",
388                        SOLO_MP4E_EXT_ADDR(solo_dev),
389                        SOLO_MP4E_EXT_SIZE(solo_dev));
390 
391         out += sprintf(out, "JPEG: 0x%08x @ 0x%08x\n",
392                        SOLO_JPEG_EXT_ADDR(solo_dev),
393                        SOLO_JPEG_EXT_SIZE(solo_dev));
394 
395         return out - buf;
396 }
397 
398 static ssize_t sdram_show(struct file *file, struct kobject *kobj,
399                           struct bin_attribute *a, char *buf,
400                           loff_t off, size_t count)
401 {
402         struct device *dev = container_of(kobj, struct device, kobj);
403         struct solo_dev *solo_dev =
404                 container_of(dev, struct solo_dev, dev);
405         const int size = solo_dev->sdram_size;
406 
407         if (off >= size)
408                 return 0;
409 
410         if (off + count > size)
411                 count = size - off;
412 
413         if (solo_p2m_dma(solo_dev, 0, buf, off, count, 0, 0))
414                 return -EIO;
415 
416         return count;
417 }
418 
419 static const struct device_attribute solo_dev_attrs[] = {
420         __ATTR(eeprom, 0640, eeprom_show, eeprom_store),
421         __ATTR(p2m_timeout, 0644, p2m_timeout_show, p2m_timeout_store),
422         __ATTR_RO(p2m_timeouts),
423         __ATTR_RO(sdram_size),
424         __ATTR_RO(tw28xx),
425         __ATTR_RO(input_map),
426         __ATTR_RO(intervals),
427         __ATTR_RO(sdram_offsets),
428 };
429 
430 static void solo_device_release(struct device *dev)
431 {
432         /* Do nothing */
433 }
434 
435 static int solo_sysfs_init(struct solo_dev *solo_dev)
436 {
437         struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
438         struct device *dev = &solo_dev->dev;
439         const char *driver;
440         int i;
441 
442         if (solo_dev->type == SOLO_DEV_6110)
443                 driver = "solo6110";
444         else
445                 driver = "solo6010";
446 
447         dev->release = solo_device_release;
448         dev->parent = &solo_dev->pdev->dev;
449         set_dev_node(dev, dev_to_node(&solo_dev->pdev->dev));
450         dev_set_name(dev, "%s-%d-%d", driver, solo_dev->vfd->num,
451                      solo_dev->nr_chans);
452 
453         if (device_register(dev)) {
454                 dev->parent = NULL;
455                 return -ENOMEM;
456         }
457 
458         for (i = 0; i < ARRAY_SIZE(solo_dev_attrs); i++) {
459                 if (device_create_file(dev, &solo_dev_attrs[i])) {
460                         device_unregister(dev);
461                         return -ENOMEM;
462                 }
463         }
464 
465         sysfs_attr_init(&sdram_attr->attr);
466         sdram_attr->attr.name = "sdram";
467         sdram_attr->attr.mode = 0440;
468         sdram_attr->read = sdram_show;
469         sdram_attr->size = solo_dev->sdram_size;
470 
471         if (device_create_bin_file(dev, sdram_attr)) {
472                 device_unregister(dev);
473                 return -ENOMEM;
474         }
475 
476         return 0;
477 }
478 
479 static int solo_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
480 {
481         struct solo_dev *solo_dev;
482         int ret;
483         u8 chip_id;
484 
485         solo_dev = kzalloc(sizeof(*solo_dev), GFP_KERNEL);
486         if (solo_dev == NULL)
487                 return -ENOMEM;
488 
489         if (id->driver_data == SOLO_DEV_6010)
490                 dev_info(&pdev->dev, "Probing Softlogic 6010\n");
491         else
492                 dev_info(&pdev->dev, "Probing Softlogic 6110\n");
493 
494         solo_dev->type = id->driver_data;
495         solo_dev->pdev = pdev;
496         spin_lock_init(&solo_dev->reg_io_lock);
497         ret = v4l2_device_register(&pdev->dev, &solo_dev->v4l2_dev);
498         if (ret)
499                 goto fail_probe;
500 
501         /* Only for during init */
502         solo_dev->p2m_jiffies = msecs_to_jiffies(100);
503 
504         ret = pci_enable_device(pdev);
505         if (ret)
506                 goto fail_probe;
507 
508         pci_set_master(pdev);
509 
510         /* RETRY/TRDY Timeout disabled */
511         pci_write_config_byte(pdev, 0x40, 0x00);
512         pci_write_config_byte(pdev, 0x41, 0x00);
513 
514         ret = pci_request_regions(pdev, SOLO6X10_NAME);
515         if (ret)
516                 goto fail_probe;
517 
518         solo_dev->reg_base = pci_ioremap_bar(pdev, 0);
519         if (solo_dev->reg_base == NULL) {
520                 ret = -ENOMEM;
521                 goto fail_probe;
522         }
523 
524         chip_id = solo_reg_read(solo_dev, SOLO_CHIP_OPTION) &
525                                 SOLO_CHIP_ID_MASK;
526         switch (chip_id) {
527         case 7:
528                 solo_dev->nr_chans = 16;
529                 solo_dev->nr_ext = 5;
530                 break;
531         case 6:
532                 solo_dev->nr_chans = 8;
533                 solo_dev->nr_ext = 2;
534                 break;
535         default:
536                 dev_warn(&pdev->dev, "Invalid chip_id 0x%02x, assuming 4 ch\n",
537                          chip_id);
538         case 5:
539                 solo_dev->nr_chans = 4;
540                 solo_dev->nr_ext = 1;
541         }
542 
543         /* Disable all interrupts to start */
544         solo_irq_off(solo_dev, ~0);
545 
546         /* Initial global settings */
547         if (solo_dev->type == SOLO_DEV_6010) {
548                 solo_dev->clock_mhz = 108;
549                 solo_dev->sys_config = SOLO_SYS_CFG_SDRAM64BIT
550                         | SOLO_SYS_CFG_INPUTDIV(25)
551                         | SOLO_SYS_CFG_FEEDBACKDIV(solo_dev->clock_mhz * 2 - 2)
552                         | SOLO_SYS_CFG_OUTDIV(3);
553                 solo_reg_write(solo_dev, SOLO_SYS_CFG, solo_dev->sys_config);
554         } else {
555                 u32 divq, divf;
556 
557                 solo_dev->clock_mhz = 135;
558 
559                 if (solo_dev->clock_mhz < 125) {
560                         divq = 3;
561                         divf = (solo_dev->clock_mhz * 4) / 3 - 1;
562                 } else {
563                         divq = 2;
564                         divf = (solo_dev->clock_mhz * 2) / 3 - 1;
565                 }
566 
567                 solo_reg_write(solo_dev, SOLO_PLL_CONFIG,
568                                (1 << 20) | /* PLL_RANGE */
569                                (8 << 15) | /* PLL_DIVR  */
570                                (divq << 12) |
571                                (divf <<  4) |
572                                (1 <<  1)   /* PLL_FSEN */);
573 
574                 solo_dev->sys_config = SOLO_SYS_CFG_SDRAM64BIT;
575         }
576 
577         solo_reg_write(solo_dev, SOLO_SYS_CFG, solo_dev->sys_config);
578         solo_reg_write(solo_dev, SOLO_TIMER_CLOCK_NUM,
579                        solo_dev->clock_mhz - 1);
580 
581         /* PLL locking time of 1ms */
582         mdelay(1);
583 
584         ret = request_irq(pdev->irq, solo_isr, IRQF_SHARED, SOLO6X10_NAME,
585                           solo_dev);
586         if (ret)
587                 goto fail_probe;
588 
589         /* Handle this from the start */
590         solo_irq_on(solo_dev, SOLO_IRQ_PCI_ERR);
591 
592         ret = solo_i2c_init(solo_dev);
593         if (ret)
594                 goto fail_probe;
595 
596         /* Setup the DMA engine */
597         solo_reg_write(solo_dev, SOLO_DMA_CTRL,
598                        SOLO_DMA_CTRL_REFRESH_CYCLE(1) |
599                        SOLO_DMA_CTRL_SDRAM_SIZE(2) |
600                        SOLO_DMA_CTRL_SDRAM_CLK_INVERT |
601                        SOLO_DMA_CTRL_READ_CLK_SELECT |
602                        SOLO_DMA_CTRL_LATENCY(1));
603 
604         /* Undocumented crap */
605         solo_reg_write(solo_dev, SOLO_DMA_CTRL1,
606                        solo_dev->type == SOLO_DEV_6010 ? 0x100 : 0x300);
607 
608         if (solo_dev->type != SOLO_DEV_6010) {
609                 solo_dev->usec_lsb = 0x3f;
610                 solo_set_time(solo_dev);
611         }
612 
613         /* Disable watchdog */
614         solo_reg_write(solo_dev, SOLO_WATCHDOG, 0);
615 
616         /* Initialize sub components */
617 
618         ret = solo_p2m_init(solo_dev);
619         if (ret)
620                 goto fail_probe;
621 
622         ret = solo_disp_init(solo_dev);
623         if (ret)
624                 goto fail_probe;
625 
626         ret = solo_gpio_init(solo_dev);
627         if (ret)
628                 goto fail_probe;
629 
630         ret = solo_tw28_init(solo_dev);
631         if (ret)
632                 goto fail_probe;
633 
634         ret = solo_v4l2_init(solo_dev, video_nr);
635         if (ret)
636                 goto fail_probe;
637 
638         ret = solo_enc_init(solo_dev);
639         if (ret)
640                 goto fail_probe;
641 
642         ret = solo_enc_v4l2_init(solo_dev, video_nr);
643         if (ret)
644                 goto fail_probe;
645 
646         ret = solo_g723_init(solo_dev);
647         if (ret)
648                 goto fail_probe;
649 
650         ret = solo_sysfs_init(solo_dev);
651         if (ret)
652                 goto fail_probe;
653 
654         /* Now that init is over, set this lower */
655         solo_dev->p2m_jiffies = msecs_to_jiffies(20);
656 
657         return 0;
658 
659 fail_probe:
660         free_solo_dev(solo_dev);
661         return ret;
662 }
663 
664 static void solo_pci_remove(struct pci_dev *pdev)
665 {
666         struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev);
667         struct solo_dev *solo_dev = container_of(v4l2_dev, struct solo_dev, v4l2_dev);
668 
669         free_solo_dev(solo_dev);
670 }
671 
672 static const struct pci_device_id solo_id_table[] = {
673         /* 6010 based cards */
674         { PCI_DEVICE(PCI_VENDOR_ID_SOFTLOGIC, PCI_DEVICE_ID_SOLO6010),
675           .driver_data = SOLO_DEV_6010 },
676         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_NEUSOLO_4),
677           .driver_data = SOLO_DEV_6010 },
678         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_NEUSOLO_9),
679           .driver_data = SOLO_DEV_6010 },
680         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_NEUSOLO_16),
681           .driver_data = SOLO_DEV_6010 },
682         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_BC_SOLO_4),
683           .driver_data = SOLO_DEV_6010 },
684         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_BC_SOLO_9),
685           .driver_data = SOLO_DEV_6010 },
686         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_BC_SOLO_16),
687           .driver_data = SOLO_DEV_6010 },
688         /* 6110 based cards */
689         { PCI_DEVICE(PCI_VENDOR_ID_SOFTLOGIC, PCI_DEVICE_ID_SOLO6110),
690           .driver_data = SOLO_DEV_6110 },
691         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_BC_6110_4),
692           .driver_data = SOLO_DEV_6110 },
693         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_BC_6110_8),
694           .driver_data = SOLO_DEV_6110 },
695         { PCI_DEVICE(PCI_VENDOR_ID_BLUECHERRY, PCI_DEVICE_ID_BC_6110_16),
696           .driver_data = SOLO_DEV_6110 },
697         {0,}
698 };
699 
700 MODULE_DEVICE_TABLE(pci, solo_id_table);
701 
702 static struct pci_driver solo_pci_driver = {
703         .name = SOLO6X10_NAME,
704         .id_table = solo_id_table,
705         .probe = solo_pci_probe,
706         .remove = solo_pci_remove,
707 };
708 
709 module_pci_driver(solo_pci_driver);
710 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us