Lines Matching +full:msi +full:- +full:capable

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Derived from cx18-driver.c
7 * Copyright 2012-2015 Cisco Systems, Inc. and/or its affiliates.
16 #include <media/v4l2-event.h>
17 #include <media/v4l2-ctrls.h>
19 #include "cobalt-driver.h"
20 #include "cobalt-irq.h"
21 #include "cobalt-i2c.h"
22 #include "cobalt-v4l2.h"
23 #include "cobalt-flash.h"
24 #include "cobalt-alsa.h"
25 #include "cobalt-omnitek.h"
104 if (cobalt->have_hsma_rx) in cobalt_set_interrupt()
109 if (cobalt->have_hsma_tx) in cobalt_set_interrupt()
126 struct cobalt *cobalt = to_cobalt(sd->v4l2_dev); in cobalt_get_sd_nr()
130 if (sd == cobalt->streams[i].sd) in cobalt_get_sd_nr()
139 struct cobalt *cobalt = to_cobalt(sd->v4l2_dev); in cobalt_notify()
141 struct cobalt_stream *s = &cobalt->streams[sd_nr]; in cobalt_notify()
144 if (s->is_output) in cobalt_notify()
155 v4l2_event_queue(&s->vdev, arg); in cobalt_notify()
188 struct pci_dev *pci_dev = cobalt->pci_dev; in cobalt_pcie_status_show()
189 struct pci_dev *pci_bus_dev = cobalt->pci_dev->bus->self; in cobalt_pcie_status_show()
237 struct pci_dev *pci_dev = cobalt->pci_dev; in pcie_link_get_lanes()
248 struct pci_dev *pci_dev = cobalt->pci_dev->bus->self; in pcie_bus_link_get_lanes()
263 cobalt_info("MSI %s\n", ctrl & 1 ? "enable" : "disable"); in msi_config_show()
264 cobalt_info("MSI multiple message: Capable %u. Enable %u\n", in msi_config_show()
267 cobalt_info("MSI: 64-bit address capable\n"); in msi_config_show()
272 cobalt_info("MSI: Address 0x%08x%08x. Data 0x%04x\n", in msi_config_show()
275 cobalt_info("MSI: Address 0x%08x. Data 0x%04x\n", in msi_config_show()
281 if (cobalt->bar0) { in cobalt_pci_iounmap()
282 pci_iounmap(pci_dev, cobalt->bar0); in cobalt_pci_iounmap()
283 cobalt->bar0 = NULL; in cobalt_pci_iounmap()
285 if (cobalt->bar1) { in cobalt_pci_iounmap()
286 pci_iounmap(pci_dev, cobalt->bar1); in cobalt_pci_iounmap()
287 cobalt->bar1 = NULL; in cobalt_pci_iounmap()
293 free_irq(pci_dev->irq, (void *)cobalt); in cobalt_free_msi()
311 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &cobalt->card_rev); in cobalt_setup_pci()
312 pci_read_config_word(pci_dev, PCI_DEVICE_ID, &cobalt->device_id); in cobalt_setup_pci()
314 switch (cobalt->device_id) { in cobalt_setup_pci()
331 ret = -EIO; in cobalt_setup_pci()
336 if (dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(64))) { in cobalt_setup_pci()
337 ret = dma_set_mask(&pci_dev->dev, DMA_BIT_MASK(32)); in cobalt_setup_pci()
352 cobalt->bar0 = pci_iomap(pci_dev, 0, 0); in cobalt_setup_pci()
353 cobalt->bar1 = pci_iomap(pci_dev, 1, 0); in cobalt_setup_pci()
354 if (cobalt->bar1 == NULL) { in cobalt_setup_pci()
355 cobalt->bar1 = pci_iomap(pci_dev, 2, 0); in cobalt_setup_pci()
356 cobalt_info("64-bit BAR\n"); in cobalt_setup_pci()
358 if (!cobalt->bar0 || !cobalt->bar1) { in cobalt_setup_pci()
359 ret = -EIO; in cobalt_setup_pci()
372 cobalt_err("Could not enable MSI\n"); in cobalt_setup_pci()
373 ret = -EIO; in cobalt_setup_pci()
379 if (request_irq(pci_dev->irq, cobalt_irq_handler, IRQF_SHARED, in cobalt_setup_pci()
380 cobalt->v4l2_dev.name, (void *)cobalt)) { in cobalt_setup_pci()
381 cobalt_err("Failed to register irq %d\n", pci_dev->irq); in cobalt_setup_pci()
382 ret = -EIO; in cobalt_setup_pci()
397 pci_disable_device(cobalt->pci_dev); in cobalt_setup_pci()
406 cobalt->hdl_info[i] = in cobalt_hdl_info_get()
407 ioread8(cobalt->bar1 + COBALT_HDL_INFO_BASE + i); in cobalt_hdl_info_get()
408 cobalt->hdl_info[COBALT_HDL_INFO_SIZE - 1] = '\0'; in cobalt_hdl_info_get()
409 if (strstr(cobalt->hdl_info, COBALT_HDL_SEARCH_STR)) in cobalt_hdl_info_get()
420 struct cobalt_stream *s = &cobalt->streams[i]; in cobalt_stream_struct_init()
422 s->cobalt = cobalt; in cobalt_stream_struct_init()
423 s->flags = 0; in cobalt_stream_struct_init()
424 s->is_audio = false; in cobalt_stream_struct_init()
425 s->is_output = false; in cobalt_stream_struct_init()
426 s->is_dummy = true; in cobalt_stream_struct_init()
430 * stream 0-3. The other can use stream struct from 4 and in cobalt_stream_struct_init()
433 s->dma_channel = i + cobalt->first_fifo_channel; in cobalt_stream_struct_init()
434 s->video_channel = i; in cobalt_stream_struct_init()
435 s->dma_fifo_mask = in cobalt_stream_struct_init()
437 s->adv_irq_mask = in cobalt_stream_struct_init()
441 unsigned idx = i - COBALT_AUDIO_IN_STREAM; in cobalt_stream_struct_init()
443 s->dma_channel = 6 + idx; in cobalt_stream_struct_init()
444 s->is_audio = true; in cobalt_stream_struct_init()
445 s->video_channel = idx; in cobalt_stream_struct_init()
446 s->dma_fifo_mask = COBALT_SYSSTAT_AUD_IN_LOST_DATA_MSK; in cobalt_stream_struct_init()
448 s->dma_channel = 11; in cobalt_stream_struct_init()
449 s->is_output = true; in cobalt_stream_struct_init()
450 s->video_channel = 5; in cobalt_stream_struct_init()
451 s->dma_fifo_mask = COBALT_SYSSTAT_VOHSMA_LOST_DATA_MSK; in cobalt_stream_struct_init()
452 s->adv_irq_mask = COBALT_SYSSTAT_VOHSMA_INT1_MSK; in cobalt_stream_struct_init()
454 s->dma_channel = 12; in cobalt_stream_struct_init()
455 s->is_audio = true; in cobalt_stream_struct_init()
456 s->is_output = true; in cobalt_stream_struct_init()
457 s->video_channel = 5; in cobalt_stream_struct_init()
458 s->dma_fifo_mask = COBALT_SYSSTAT_AUD_OUT_LOST_DATA_MSK; in cobalt_stream_struct_init()
461 s->dma_channel = i - COBALT_NUM_NODES; in cobalt_stream_struct_init()
463 cobalt_info("stream #%d -> dma channel #%d <- video channel %d\n", in cobalt_stream_struct_init()
464 i, s->dma_channel, s->video_channel); in cobalt_stream_struct_init()
490 struct cobalt_stream *s = cobalt->streams; in cobalt_subdevs_init()
508 s[i].i2c_adap = &cobalt->i2c_adap[i]; in cobalt_subdevs_init()
509 if (s[i].i2c_adap->dev.parent == NULL) in cobalt_subdevs_init()
513 s[i].sd = v4l2_i2c_new_subdev_board(&cobalt->v4l2_dev, in cobalt_subdevs_init()
518 return -ENODEV; in cobalt_subdevs_init()
540 cobalt->streams[i + COBALT_AUDIO_IN_STREAM].is_dummy = false; in cobalt_subdevs_init()
588 .type = "adv7511-v4l2", in cobalt_subdevs_hsma_init()
598 struct cobalt_stream *s = &cobalt->streams[COBALT_HSMA_IN_NODE]; in cobalt_subdevs_hsma_init()
600 s->i2c_adap = &cobalt->i2c_adap[COBALT_NUM_ADAPTERS - 1]; in cobalt_subdevs_hsma_init()
601 if (s->i2c_adap->dev.parent == NULL) in cobalt_subdevs_hsma_init()
605 s->sd = v4l2_i2c_new_subdev_board(&cobalt->v4l2_dev, in cobalt_subdevs_hsma_init()
606 s->i2c_adap, &adv7842_info, NULL); in cobalt_subdevs_hsma_init()
607 if (s->sd) { in cobalt_subdevs_hsma_init()
608 int err = v4l2_subdev_call(s->sd, pad, set_edid, &cobalt_edid); in cobalt_subdevs_hsma_init()
612 err = v4l2_subdev_call(s->sd, pad, set_fmt, NULL, in cobalt_subdevs_hsma_init()
616 cobalt->have_hsma_rx = true; in cobalt_subdevs_hsma_init()
617 s->pad_source = ADV7842_PAD_SOURCE; in cobalt_subdevs_hsma_init()
618 s->is_dummy = false; in cobalt_subdevs_hsma_init()
619 cobalt->streams[4 + COBALT_AUDIO_IN_STREAM].is_dummy = false; in cobalt_subdevs_hsma_init()
632 s->i2c_adap = &cobalt->i2c_adap[COBALT_NUM_ADAPTERS - 1]; in cobalt_subdevs_hsma_init()
633 s->sd = v4l2_i2c_new_subdev_board(&cobalt->v4l2_dev, in cobalt_subdevs_hsma_init()
634 s->i2c_adap, &adv7511_info, NULL); in cobalt_subdevs_hsma_init()
635 if (s->sd) { in cobalt_subdevs_hsma_init()
643 cobalt->have_hsma_tx = true; in cobalt_subdevs_hsma_init()
644 v4l2_subdev_call(s->sd, core, s_power, 1); in cobalt_subdevs_hsma_init()
645 v4l2_subdev_call(s->sd, video, s_stream, 1); in cobalt_subdevs_hsma_init()
646 v4l2_subdev_call(s->sd, audio, s_stream, 1); in cobalt_subdevs_hsma_init()
647 v4l2_ctrl_s_ctrl(v4l2_ctrl_find(s->sd->ctrl_handler, in cobalt_subdevs_hsma_init()
649 s->is_dummy = false; in cobalt_subdevs_hsma_init()
650 cobalt->streams[COBALT_AUDIO_OUT_STREAM].is_dummy = false; in cobalt_subdevs_hsma_init()
653 return -ENODEV; in cobalt_subdevs_hsma_init()
663 /* FIXME - module parameter arrays constrain max instances */ in cobalt_probe()
664 i = atomic_inc_return(&cobalt_instance) - 1; in cobalt_probe()
668 return -ENOMEM; in cobalt_probe()
669 cobalt->pci_dev = pci_dev; in cobalt_probe()
670 cobalt->instance = i; in cobalt_probe()
671 mutex_init(&cobalt->pci_lock); in cobalt_probe()
673 retval = v4l2_device_register(&pci_dev->dev, &cobalt->v4l2_dev); in cobalt_probe()
676 cobalt->instance); in cobalt_probe()
680 snprintf(cobalt->v4l2_dev.name, sizeof(cobalt->v4l2_dev.name), in cobalt_probe()
681 "cobalt-%d", cobalt->instance); in cobalt_probe()
682 cobalt->v4l2_dev.notify = cobalt_notify; in cobalt_probe()
683 cobalt_info("Initializing card %d\n", cobalt->instance); in cobalt_probe()
685 cobalt->irq_work_queues = in cobalt_probe()
686 create_singlethread_workqueue(cobalt->v4l2_dev.name); in cobalt_probe()
687 if (cobalt->irq_work_queues == NULL) { in cobalt_probe()
689 retval = -ENOMEM; in cobalt_probe()
693 INIT_WORK(&cobalt->irq_work_queue, cobalt_irq_work_handler); in cobalt_probe()
704 cobalt_info("%s", cobalt->hdl_info); in cobalt_probe()
729 v4l2_device_call_all(&cobalt->v4l2_dev, 0, core, in cobalt_probe()
744 pci_release_regions(cobalt->pci_dev); in cobalt_probe()
745 pci_disable_device(cobalt->pci_dev); in cobalt_probe()
747 destroy_workqueue(cobalt->irq_work_queues); in cobalt_probe()
751 v4l2_device_unregister(&cobalt->v4l2_dev); in cobalt_probe()
764 flush_workqueue(cobalt->irq_work_queues); in cobalt_remove()
767 struct v4l2_subdev *sd = cobalt->streams[i].sd; in cobalt_remove()
780 pci_release_regions(cobalt->pci_dev); in cobalt_remove()
781 pci_disable_device(cobalt->pci_dev); in cobalt_remove()
782 destroy_workqueue(cobalt->irq_work_queues); in cobalt_remove()