DMA_Slot Class Reference
#include <dma_slot.h>
Collaboration diagram for DMA_Slot:

Public Member Functions | |
| DMA_Slot () | |
| void | deny_use () |
| void | allow_use () |
| void | detach_camera () |
| void | attach_camera (Mr1394_Hw_Camera *pcam_ptr, float bandwidth) |
Static Public Member Functions | |
| static float | get_available_isochronous_bus_bandwidth () |
| static DMA_Slot * | wait_for_dma_slot () |
Static Public Attributes | |
| static const int | DMA_SLOT_COUNT = 4 |
Private Attributes | |
| Mr1394_Hw_Camera * | _pcam_ptr |
| float | _bandwidth |
| bool | _allow_usage |
Classes | |
| class | DMA_Resource_Guard |
Detailed Description
Definition at line 3 of file dma_slot.h.
Constructor & Destructor Documentation
| DMA_Slot::DMA_Slot | ( | ) |
Definition at line 53 of file dma_slot.cc.
00054 : _pcam_ptr(NULL), 00055 _bandwidth(0.0), 00056 _allow_usage(true) 00057 { }
Member Function Documentation
| float DMA_Slot::get_available_isochronous_bus_bandwidth | ( | ) | [static] |
Definition at line 66 of file dma_slot.cc.
References global_available_bandwidth.
00067 { 00068 return global_available_bandwidth; 00069 }
| DMA_Slot * DMA_Slot::wait_for_dma_slot | ( | ) | [static] |
Definition at line 161 of file dma_slot.cc.
References _allow_usage, _pcam_ptr, detach_camera(), dma_slot, DMA_SLOT_COUNT, global_available_slot_counting_sem(), global_next_dma_slot, Mr1394_Hw_Camera::lock(), and Mr1394_Hw_Camera::unlock().
Referenced by grab_all_resources().
00162 { 00163 // Wait for a slot to become available. 00164 global_available_slot_counting_sem.acquire(); 00165 00166 // We know there is an available slot. Find it. 00167 int j = global_next_dma_slot; 00168 do { 00169 if (dma_slot[j]._allow_usage) { 00170 Mr1394_Hw_Camera* pcam_ptr = dma_slot[j]._pcam_ptr; 00171 if (pcam_ptr != NULL) { 00172 // dma_slot is available ==> its camera will be unlocked. 00173 // Consequently, pcam_ptr->lock() will not block. 00174 pcam_ptr->lock(); 00175 dma_slot[j].detach_camera(); 00176 pcam_ptr->unlock(); 00177 } 00178 dma_slot[j]._allow_usage = false; 00179 ++global_next_dma_slot; 00180 if (global_next_dma_slot >= DMA_SLOT_COUNT) global_next_dma_slot = 0; 00181 return &dma_slot[j]; 00182 } 00183 ++j; 00184 if (j >= DMA_SLOT_COUNT) j = 0; 00185 } while (j != global_next_dma_slot); 00186 assert(false); 00187 return NULL; 00188 }
Here is the call graph for this function:

| void DMA_Slot::deny_use | ( | ) |
Definition at line 81 of file dma_slot.cc.
References _allow_usage, and global_available_slot_counting_sem().
Referenced by grab_all_resources().
00082 { 00083 if (_allow_usage) { 00084 // This DMA slot is not use exclusively, so the following acquire 00085 // should not block. 00086 global_available_slot_counting_sem.acquire(); 00087 _allow_usage = false; 00088 } 00089 }
Here is the call graph for this function:

| void DMA_Slot::allow_use | ( | ) |
Definition at line 103 of file dma_slot.cc.
References _allow_usage, and global_available_slot_counting_sem().
Referenced by Mr1394_Camera::~Mr1394_Camera().
00104 { 00105 if (!_allow_usage) { 00106 _allow_usage = true; 00107 global_available_slot_counting_sem.release(); 00108 } 00109 }
Here is the call graph for this function:

| void DMA_Slot::detach_camera | ( | ) |
Definition at line 118 of file dma_slot.cc.
References _bandwidth, _pcam_ptr, Mr1394_Hw_Camera::dma_slot_ptr, global_available_bandwidth, and Mr1394_Hw_Camera::to_unready_state().
Referenced by wait_for_dma_slot(), and Mr1394_Camera::~Mr1394_Camera().
00119 { 00120 if (_pcam_ptr != NULL) { 00121 _pcam_ptr->to_unready_state(); 00122 global_available_bandwidth += _bandwidth; 00123 _bandwidth = 0.0; 00124 _pcam_ptr->dma_slot_ptr = NULL; 00125 _pcam_ptr = NULL; 00126 } 00127 }
Here is the call graph for this function:

| void DMA_Slot::attach_camera | ( | Mr1394_Hw_Camera * | pcam_ptr, | |
| float | bandwidth | |||
| ) |
Definition at line 141 of file dma_slot.cc.
References _bandwidth, _pcam_ptr, Mr1394_Hw_Camera::dma_slot_ptr, and global_available_bandwidth.
Referenced by dma_slot_attach_camera().
00142 { 00143 // dma_slot may already be active 00144 assert(_pcam_ptr == NULL || _pcam_ptr == pcam_ptr); 00145 _pcam_ptr = pcam_ptr; 00146 _pcam_ptr->dma_slot_ptr = this; 00147 global_available_bandwidth += _bandwidth; 00148 _bandwidth = bandwidth; 00149 global_available_bandwidth -= _bandwidth; 00150 }
Member Data Documentation
const int DMA_Slot::DMA_SLOT_COUNT = 4 [static] |
Definition at line 11 of file dma_slot.h.
Referenced by grab_all_resources(), and wait_for_dma_slot().
Mr1394_Hw_Camera* DMA_Slot::_pcam_ptr [private] |
Definition at line 22 of file dma_slot.h.
Referenced by attach_camera(), detach_camera(), and wait_for_dma_slot().
float DMA_Slot::_bandwidth [private] |
bool DMA_Slot::_allow_usage [private] |
Definition at line 24 of file dma_slot.h.
Referenced by allow_use(), deny_use(), and wait_for_dma_slot().
The documentation for this class was generated from the following files: