/** * hpi_validate_response - Given an HPI Message that was sent out and * a response that was received, validate that the response has the * correct fields filled in, i.e ObjectType, Function etc * @phm: message * @phr: response
*/
u16 hpi_validate_response(struct hpi_message *phm, struct hpi_response *phr)
{ if (phr->type != HPI_TYPE_RESPONSE) {
HPI_DEBUG_LOG(ERROR, "header type %d invalid\n", phr->type); return HPI_ERROR_INVALID_RESPONSE;
}
if (adapters.adapter[pao->index].type) { int a; for (a = HPI_MAX_ADAPTERS - 1; a >= 0; a--) { if (!adapters.adapter[a].type) {
HPI_DEBUG_LOG(WARNING, "ASI%X duplicate index %d moved to %d\n",
pao->type, pao->index, a);
pao->index = a; break;
}
} if (a < 0) {
retval = HPI_ERROR_DUPLICATE_ADAPTER_NUMBER; goto unlock;
}
}
adapters.adapter[pao->index] = *pao;
hpios_dsplock_init(&adapters.adapter[pao->index]);
adapters.gw_num_adapters++;
hpios_alistlock_lock(&adapters); if (adapters.adapter[pao->index].type)
adapters.gw_num_adapters--;
memset(&adapters.adapter[pao->index], 0, sizeof(adapters.adapter[0]));
hpios_alistlock_unlock(&adapters);
}
/** * hpi_find_adapter - FindAdapter returns a pointer to the struct * hpi_adapter_obj with index wAdapterIndex in an HPI_ADAPTERS_LIST * structure. * @adapter_index: value in [0, HPI_MAX_ADAPTERS[
*/ struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index)
{ struct hpi_adapter_obj *pao = NULL;
if (adapter_index >= HPI_MAX_ADAPTERS) {
HPI_DEBUG_LOG(VERBOSE, "find_adapter invalid index %d\n",
adapter_index); return NULL;
}
pao = &adapters.adapter[adapter_index]; if (pao->type != 0) { /* HPI_DEBUG_LOG(VERBOSE, "Found adapter index %d\n", wAdapterIndex);
*/ return pao;
} else { /* HPI_DEBUG_LOG(VERBOSE, "No adapter index %d\n", wAdapterIndex);
*/ return NULL;
}
}
staticvoid subsys_get_adapter(struct hpi_message *phm, struct hpi_response *phr)
{ int count = phm->obj_index;
u16 index = 0;
/* find the nCount'th nonzero adapter in array */ for (index = 0; index < HPI_MAX_ADAPTERS; index++) { if (adapters.adapter[index].type) { if (!count) break;
count--;
}
}
p_master_cache = (char *)pC->p_cache;
HPI_DEBUG_LOG(DEBUG, "check %d controls\n",
pC->control_count); for (i = 0; i < pC->control_count; i++) { struct hpi_control_cache_info *info =
(struct hpi_control_cache_info *)
&p_master_cache[byte_count];
u16 control_index = info->control_index;
if (control_index >= pC->control_count) {
HPI_DEBUG_LOG(INFO, "adap %d control index %d out of range, cache not ready?\n",
pC->adap_idx, control_index); return 0;
}
if (!info->size_in32bit_words) { if (!i) {
HPI_DEBUG_LOG(INFO, "adap %d cache not ready?\n",
pC->adap_idx); return 0;
} /* The cache is invalid. * Minimum valid entry size is * sizeof(struct hpi_control_cache_info)
*/
HPI_DEBUG_LOG(ERROR, "adap %d zero size cache entry %d\n",
pC->adap_idx, i); break;
}
HPI_DEBUG_LOG(VERBOSE, "cached %d, pinfo %p index %d type %d size %d\n",
cached, pC->p_info[info->control_index],
info->control_index, info->control_type,
info->size_in32bit_words);
/* quit loop early if whole cache has been scanned. * dwControlCount is the maximum possible entries * but some may be absent from the cache
*/ if (byte_count >= pC->cache_size_in_bytes) break; /* have seen last control index */ if (info->control_index == pC->control_count - 1) break;
}
/** CheckControlCache checks the cache and fills the struct hpi_response * accordingly. It returns one if a cache hit occurred, zero otherwise.
*/ short hpi_check_control_cache_single(struct hpi_control_cache_single *pC, struct hpi_message *phm, struct hpi_response *phr)
{
size_t response_size; short found = 1;
/* set the default response size */
response_size = sizeof(struct hpi_response_header) + sizeof(struct hpi_control_res);
switch (pC->u.i.control_type) {
case HPI_CONTROL_METER: if (phm->u.c.attribute == HPI_METER_PEAK) {
phr->u.c.an_log_value[0] = pC->u.meter.an_log_peak[0];
phr->u.c.an_log_value[1] = pC->u.meter.an_log_peak[1];
} elseif (phm->u.c.attribute == HPI_METER_RMS) { if (pC->u.meter.an_logRMS[0] ==
HPI_CACHE_INVALID_SHORT) {
phr->error =
HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
phr->u.c.an_log_value[0] = HPI_METER_MINIMUM;
phr->u.c.an_log_value[1] = HPI_METER_MINIMUM;
} else {
phr->u.c.an_log_value[0] =
pC->u.meter.an_logRMS[0];
phr->u.c.an_log_value[1] =
pC->u.meter.an_logRMS[1];
}
} else
found = 0; break; case HPI_CONTROL_VOLUME: if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
phr->u.c.an_log_value[0] = pC->u.vol.an_log[0];
phr->u.c.an_log_value[1] = pC->u.vol.an_log[1];
} elseif (phm->u.c.attribute == HPI_VOLUME_MUTE) { if (pC->u.vol.flags & HPI_VOLUME_FLAG_HAS_MUTE) { if (pC->u.vol.flags & HPI_VOLUME_FLAG_MUTED)
phr->u.c.param1 =
HPI_BITMASK_ALL_CHANNELS; else
phr->u.c.param1 = 0;
} else {
phr->error =
HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
phr->u.c.param1 = 0;
}
} else {
found = 0;
} break; case HPI_CONTROL_MULTIPLEXER: if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
phr->u.c.param1 = pC->u.mux.source_node_type;
phr->u.c.param2 = pC->u.mux.source_node_index;
} else {
found = 0;
} break; case HPI_CONTROL_CHANNEL_MODE: if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
phr->u.c.param1 = pC->u.mode.mode; else
found = 0; break; case HPI_CONTROL_LEVEL: if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
phr->u.c.an_log_value[0] = pC->u.level.an_log[0];
phr->u.c.an_log_value[1] = pC->u.level.an_log[1];
} else
found = 0; break; case HPI_CONTROL_TUNER: if (phm->u.c.attribute == HPI_TUNER_FREQ)
phr->u.c.param1 = pC->u.tuner.freq_ink_hz; elseif (phm->u.c.attribute == HPI_TUNER_BAND)
phr->u.c.param1 = pC->u.tuner.band; elseif (phm->u.c.attribute == HPI_TUNER_LEVEL_AVG) if (pC->u.tuner.s_level_avg ==
HPI_CACHE_INVALID_SHORT) {
phr->u.cu.tuner.s_level = 0;
phr->error =
HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
} else
phr->u.cu.tuner.s_level =
pC->u.tuner.s_level_avg; else
found = 0; break; case HPI_CONTROL_AESEBU_RECEIVER: if (phm->u.c.attribute == HPI_AESEBURX_ERRORSTATUS)
phr->u.c.param1 = pC->u.aes3rx.error_status; elseif (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
phr->u.c.param1 = pC->u.aes3rx.format; else
found = 0; break; case HPI_CONTROL_AESEBU_TRANSMITTER: if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT)
phr->u.c.param1 = pC->u.aes3tx.format; else
found = 0; break; case HPI_CONTROL_TONEDETECTOR: if (phm->u.c.attribute == HPI_TONEDETECTOR_STATE)
phr->u.c.param1 = pC->u.tone.state; else
found = 0; break; case HPI_CONTROL_SILENCEDETECTOR: if (phm->u.c.attribute == HPI_SILENCEDETECTOR_STATE) {
phr->u.c.param1 = pC->u.silence.state;
} else
found = 0; break; case HPI_CONTROL_MICROPHONE: if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
phr->u.c.param1 = pC->u.microphone.phantom_state; else
found = 0; break; case HPI_CONTROL_SAMPLECLOCK: if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE)
phr->u.c.param1 = pC->u.clk.source; elseif (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX) { if (pC->u.clk.source_index ==
HPI_CACHE_INVALID_UINT16) {
phr->u.c.param1 = 0;
phr->error =
HPI_ERROR_INVALID_CONTROL_ATTRIBUTE;
} else
phr->u.c.param1 = pC->u.clk.source_index;
} elseif (phm->u.c.attribute == HPI_SAMPLECLOCK_SAMPLERATE)
phr->u.c.param1 = pC->u.clk.sample_rate; else
found = 0; break; case HPI_CONTROL_PAD:{ struct hpi_control_cache_pad *p_pad;
p_pad = (struct hpi_control_cache_pad *)pC;
Only update if no error. Volume and Level return the limited values in the response, so use these Multiplexer does so use sent values
*/ void hpi_cmn_control_cache_sync_to_msg_single(struct hpi_control_cache_single
*pC, struct hpi_message *phm, struct hpi_response *phr)
{ switch (pC->u.i.control_type) { case HPI_CONTROL_VOLUME: if (phm->u.c.attribute == HPI_VOLUME_GAIN) {
pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
} elseif (phm->u.c.attribute == HPI_VOLUME_MUTE) { if (phm->u.c.param1)
pC->u.vol.flags |= HPI_VOLUME_FLAG_MUTED; else
pC->u.vol.flags &= ~HPI_VOLUME_FLAG_MUTED;
} break; case HPI_CONTROL_MULTIPLEXER: /* mux does not return its setting on Set command. */ if (phm->u.c.attribute == HPI_MULTIPLEXER_SOURCE) {
pC->u.mux.source_node_type = (u16)phm->u.c.param1;
pC->u.mux.source_node_index = (u16)phm->u.c.param2;
} break; case HPI_CONTROL_CHANNEL_MODE: /* mode does not return its setting on Set command. */ if (phm->u.c.attribute == HPI_CHANNEL_MODE_MODE)
pC->u.mode.mode = (u16)phm->u.c.param1; break; case HPI_CONTROL_LEVEL: if (phm->u.c.attribute == HPI_LEVEL_GAIN) {
pC->u.vol.an_log[0] = phr->u.c.an_log_value[0];
pC->u.vol.an_log[1] = phr->u.c.an_log_value[1];
} break; case HPI_CONTROL_MICROPHONE: if (phm->u.c.attribute == HPI_MICROPHONE_PHANTOM_POWER)
pC->u.microphone.phantom_state = (u16)phm->u.c.param1; break; case HPI_CONTROL_AESEBU_TRANSMITTER: if (phm->u.c.attribute == HPI_AESEBUTX_FORMAT)
pC->u.aes3tx.format = phm->u.c.param1; break; case HPI_CONTROL_AESEBU_RECEIVER: if (phm->u.c.attribute == HPI_AESEBURX_FORMAT)
pC->u.aes3rx.format = phm->u.c.param1; break; case HPI_CONTROL_SAMPLECLOCK: if (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE)
pC->u.clk.source = (u16)phm->u.c.param1; elseif (phm->u.c.attribute == HPI_SAMPLECLOCK_SOURCE_INDEX)
pC->u.clk.source_index = (u16)phm->u.c.param1; elseif (phm->u.c.attribute == HPI_SAMPLECLOCK_SAMPLERATE)
pC->u.clk.sample_rate = phm->u.c.param1; break; default: break;
}
}
if (!find_control(phm->obj_index, p_cache, &pI)) {
HPI_DEBUG_LOG(VERBOSE, "HPICMN find_control() failed for adap %d\n",
phm->adapter_index); return;
}
/* pC is the default cached control strucure. May be cast to something else in the following switch statement.
*/
pC = (struct hpi_control_cache_single *)pI;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.