1809
1537
return hr.error;
1812
u16 HPI_AESEBU__receiver_get_error_status(const struct hpi_hsubsys *ph_subsys,
1813
u32 h_control, u16 *pw_error_data)
1540
u16 hpi_aesebu_receiver_get_error_status(u32 h_control, u16 *pw_error_data)
1815
1542
u32 error_data = 0;
1818
error = hpi_control_param1_get(ph_subsys, h_control,
1819
HPI_AESEBURX_ERRORSTATUS, &error_data);
1545
err = hpi_control_param1_get(h_control, HPI_AESEBURX_ERRORSTATUS,
1820
1547
if (pw_error_data)
1821
1548
*pw_error_data = (u16)error_data;
1825
u16 HPI_AESEBU__transmitter_set_sample_rate(const struct hpi_hsubsys
1826
*ph_subsys, u32 h_control, u32 sample_rate)
1828
return hpi_control_param_set(ph_subsys, h_control,
1829
HPI_AESEBUTX_SAMPLERATE, sample_rate, 0);
1832
u16 HPI_AESEBU__transmitter_set_user_data(const struct hpi_hsubsys *ph_subsys,
1833
u32 h_control, u16 index, u16 data)
1835
return hpi_control_param_set(ph_subsys, h_control,
1836
HPI_AESEBUTX_USERDATA, index, data);
1839
u16 HPI_AESEBU__transmitter_set_channel_status(const struct hpi_hsubsys
1840
*ph_subsys, u32 h_control, u16 index, u16 data)
1842
return hpi_control_param_set(ph_subsys, h_control,
1843
HPI_AESEBUTX_CHANNELSTATUS, index, data);
1846
u16 HPI_AESEBU__transmitter_get_channel_status(const struct hpi_hsubsys
1847
*ph_subsys, u32 h_control, u16 index, u16 *pw_data)
1552
u16 hpi_aesebu_transmitter_set_sample_rate(u32 h_control, u32 sample_rate)
1554
return hpi_control_param_set(h_control, HPI_AESEBUTX_SAMPLERATE,
1558
u16 hpi_aesebu_transmitter_set_user_data(u32 h_control, u16 index, u16 data)
1560
return hpi_control_param_set(h_control, HPI_AESEBUTX_USERDATA, index,
1564
u16 hpi_aesebu_transmitter_set_channel_status(u32 h_control, u16 index,
1567
return hpi_control_param_set(h_control, HPI_AESEBUTX_CHANNELSTATUS,
1571
u16 hpi_aesebu_transmitter_get_channel_status(u32 h_control, u16 index,
1849
1574
return HPI_ERROR_INVALID_OPERATION;
1852
u16 HPI_AESEBU__transmitter_query_format(const struct hpi_hsubsys *ph_subsys,
1853
const u32 h_aes_tx, const u32 index, u16 *pw_format)
1577
u16 hpi_aesebu_transmitter_query_format(const u32 h_aes_tx, const u32 index,
1858
err = hpi_control_query(ph_subsys, h_aes_tx, HPI_AESEBUTX_FORMAT,
1583
err = hpi_control_query(h_aes_tx, HPI_AESEBUTX_FORMAT, index, 0, &qr);
1860
1584
*pw_format = (u16)qr;
1864
u16 HPI_AESEBU__transmitter_set_format(const struct hpi_hsubsys *ph_subsys,
1865
u32 h_control, u16 output_format)
1588
u16 hpi_aesebu_transmitter_set_format(u32 h_control, u16 output_format)
1867
return hpi_control_param_set(ph_subsys, h_control,
1868
HPI_AESEBUTX_FORMAT, output_format, 0);
1590
return hpi_control_param_set(h_control, HPI_AESEBUTX_FORMAT,
1871
u16 HPI_AESEBU__transmitter_get_format(const struct hpi_hsubsys *ph_subsys,
1872
u32 h_control, u16 *pw_output_format)
1594
u16 hpi_aesebu_transmitter_get_format(u32 h_control, u16 *pw_output_format)
1877
err = hpi_control_param1_get(ph_subsys, h_control,
1878
HPI_AESEBUTX_FORMAT, ¶m);
1599
err = hpi_control_param1_get(h_control, HPI_AESEBUTX_FORMAT, ¶m);
1879
1600
if (!err && pw_output_format)
1880
1601
*pw_output_format = (u16)param;
1885
u16 hpi_bitstream_set_clock_edge(const struct hpi_hsubsys *ph_subsys,
1886
u32 h_control, u16 edge_type)
1888
return hpi_control_param_set(ph_subsys, h_control,
1889
HPI_BITSTREAM_CLOCK_EDGE, edge_type, 0);
1892
u16 hpi_bitstream_set_data_polarity(const struct hpi_hsubsys *ph_subsys,
1893
u32 h_control, u16 polarity)
1895
return hpi_control_param_set(ph_subsys, h_control,
1896
HPI_BITSTREAM_DATA_POLARITY, polarity, 0);
1899
u16 hpi_bitstream_get_activity(const struct hpi_hsubsys *ph_subsys,
1900
u32 h_control, u16 *pw_clk_activity, u16 *pw_data_activity)
1606
u16 hpi_bitstream_set_clock_edge(u32 h_control, u16 edge_type)
1608
return hpi_control_param_set(h_control, HPI_BITSTREAM_CLOCK_EDGE,
1612
u16 hpi_bitstream_set_data_polarity(u32 h_control, u16 polarity)
1614
return hpi_control_param_set(h_control, HPI_BITSTREAM_DATA_POLARITY,
1618
u16 hpi_bitstream_get_activity(u32 h_control, u16 *pw_clk_activity,
1619
u16 *pw_data_activity)
1902
1621
struct hpi_message hm;
1903
1622
struct hpi_response hr;
1904
1623
hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
1905
1624
HPI_CONTROL_GET_STATE);
1906
u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1625
if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1626
return HPI_ERROR_INVALID_HANDLE;
1907
1627
hm.u.c.attribute = HPI_BITSTREAM_ACTIVITY;
1908
1628
hpi_send_recv(&hm, &hr);
1909
1629
if (pw_clk_activity)
2035
1754
return hr.error;
2038
u16 hpi_cobranet_getI_paddress(const struct hpi_hsubsys *ph_subsys,
2039
u32 h_control, u32 *pi_paddress)
1757
u16 hpi_cobranet_get_ip_address(u32 h_control, u32 *pdw_ip_address)
2041
1759
u32 byte_count;
2045
error = hpi_cobranet_hmi_read(ph_subsys, h_control,
1763
err = hpi_cobranet_hmi_read(h_control,
2046
1764
HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, &byte_count,
2050
1768
((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2051
1769
0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
1772
*pdw_ip_address = 0;
2060
u16 hpi_cobranet_setI_paddress(const struct hpi_hsubsys *ph_subsys,
2061
u32 h_control, u32 i_paddress)
1778
u16 hpi_cobranet_set_ip_address(u32 h_control, u32 dw_ip_address)
2066
iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) <<
2067
8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress &
2070
error = hpi_cobranet_hmi_write(ph_subsys, h_control,
1783
iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
1784
0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
1785
8) | ((dw_ip_address & 0x000000ff) << 8);
1787
err = hpi_cobranet_hmi_write(h_control,
2071
1788
HPI_COBRANET_HMI_cobra_ip_mon_currentIP, 4, (u8 *)&iP);
2077
u16 hpi_cobranet_get_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
2078
u32 h_control, u32 *pi_paddress)
1794
u16 hpi_cobranet_get_static_ip_address(u32 h_control, u32 *pdw_ip_address)
2080
1796
u32 byte_count;
2083
error = hpi_cobranet_hmi_read(ph_subsys, h_control,
1799
err = hpi_cobranet_hmi_read(h_control,
2084
1800
HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, &byte_count,
2088
1804
((iP & 0xff000000) >> 8) | ((iP & 0x00ff0000) << 8) | ((iP &
2089
1805
0x0000ff00) >> 8) | ((iP & 0x000000ff) << 8);
1808
*pdw_ip_address = 0;
2098
u16 hpi_cobranet_set_staticI_paddress(const struct hpi_hsubsys *ph_subsys,
2099
u32 h_control, u32 i_paddress)
1814
u16 hpi_cobranet_set_static_ip_address(u32 h_control, u32 dw_ip_address)
2104
iP = ((i_paddress & 0xff000000) >> 8) | ((i_paddress & 0x00ff0000) <<
2105
8) | ((i_paddress & 0x0000ff00) >> 8) | ((i_paddress &
2108
error = hpi_cobranet_hmi_write(ph_subsys, h_control,
1819
iP = ((dw_ip_address & 0xff000000) >> 8) | ((dw_ip_address &
1820
0x00ff0000) << 8) | ((dw_ip_address & 0x0000ff00) >>
1821
8) | ((dw_ip_address & 0x000000ff) << 8);
1823
err = hpi_cobranet_hmi_write(h_control,
2109
1824
HPI_COBRANET_HMI_cobra_ip_mon_staticIP, 4, (u8 *)&iP);
2115
u16 hpi_cobranet_getMA_caddress(const struct hpi_hsubsys *ph_subsys,
2116
u32 h_control, u32 *pmAC_MS_bs, u32 *pmAC_LS_bs)
1830
u16 hpi_cobranet_get_macaddress(u32 h_control, u32 *p_mac_msbs,
2118
1833
u32 byte_count;
2122
error = hpi_cobranet_hmi_read(ph_subsys, h_control,
1837
err = hpi_cobranet_hmi_read(h_control,
2123
1838
HPI_COBRANET_HMI_cobra_if_phy_address, 4, &byte_count,
2126
((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
2127
& 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
2128
error += hpi_cobranet_hmi_read(ph_subsys, h_control,
2129
HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4, &byte_count,
2132
((mAC & 0xff000000) >> 8) | ((mAC & 0x00ff0000) << 8) | ((mAC
2133
& 0x0000ff00) >> 8) | ((mAC & 0x000000ff) << 8);
2143
u16 hpi_compander_set_enable(const struct hpi_hsubsys *ph_subsys,
2144
u32 h_control, u32 enable)
2146
return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2150
u16 hpi_compander_get_enable(const struct hpi_hsubsys *ph_subsys,
2151
u32 h_control, u32 *enable)
2153
return hpi_control_param1_get(ph_subsys, h_control,
2154
HPI_GENERIC_ENABLE, enable);
2157
u16 hpi_compander_set_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2158
u32 h_control, short makeup_gain0_01dB)
1843
((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
1844
| ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
1847
err = hpi_cobranet_hmi_read(h_control,
1848
HPI_COBRANET_HMI_cobra_if_phy_address + 1, 4,
1849
&byte_count, (u8 *)&mac);
1854
((mac & 0xff000000) >> 8) | ((mac & 0x00ff0000) << 8)
1855
| ((mac & 0x0000ff00) >> 8) | ((mac & 0x000000ff) <<
1865
u16 hpi_compander_set_enable(u32 h_control, u32 enable)
1867
return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
1871
u16 hpi_compander_get_enable(u32 h_control, u32 *enable)
1873
return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
1876
u16 hpi_compander_set_makeup_gain(u32 h_control, short makeup_gain0_01dB)
2160
1878
return hpi_control_log_set2(h_control, HPI_COMPANDER_MAKEUPGAIN,
2161
1879
makeup_gain0_01dB, 0);
2164
u16 hpi_compander_get_makeup_gain(const struct hpi_hsubsys *ph_subsys,
2165
u32 h_control, short *makeup_gain0_01dB)
2167
return hpi_control_log_get2(ph_subsys, h_control,
2168
HPI_COMPANDER_MAKEUPGAIN, makeup_gain0_01dB, NULL);
2171
u16 hpi_compander_set_attack_time_constant(const struct hpi_hsubsys
2172
*ph_subsys, u32 h_control, unsigned int index, u32 attack)
2174
return hpi_control_param_set(ph_subsys, h_control,
2175
HPI_COMPANDER_ATTACK, attack, index);
2178
u16 hpi_compander_get_attack_time_constant(const struct hpi_hsubsys
2179
*ph_subsys, u32 h_control, unsigned int index, u32 *attack)
2181
return hpi_control_param_get(ph_subsys, h_control,
2182
HPI_COMPANDER_ATTACK, 0, index, attack, NULL);
2185
u16 hpi_compander_set_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2186
u32 h_control, unsigned int index, u32 decay)
2188
return hpi_control_param_set(ph_subsys, h_control,
2189
HPI_COMPANDER_DECAY, decay, index);
2192
u16 hpi_compander_get_decay_time_constant(const struct hpi_hsubsys *ph_subsys,
2193
u32 h_control, unsigned int index, u32 *decay)
2195
return hpi_control_param_get(ph_subsys, h_control,
2196
HPI_COMPANDER_DECAY, 0, index, decay, NULL);
2200
u16 hpi_compander_set_threshold(const struct hpi_hsubsys *ph_subsys,
2201
u32 h_control, unsigned int index, short threshold0_01dB)
1882
u16 hpi_compander_get_makeup_gain(u32 h_control, short *makeup_gain0_01dB)
1884
return hpi_control_log_get2(h_control, HPI_COMPANDER_MAKEUPGAIN,
1885
makeup_gain0_01dB, NULL);
1888
u16 hpi_compander_set_attack_time_constant(u32 h_control, unsigned int index,
1891
return hpi_control_param_set(h_control, HPI_COMPANDER_ATTACK, attack,
1895
u16 hpi_compander_get_attack_time_constant(u32 h_control, unsigned int index,
1898
return hpi_control_param_get(h_control, HPI_COMPANDER_ATTACK, 0,
1899
index, attack, NULL);
1902
u16 hpi_compander_set_decay_time_constant(u32 h_control, unsigned int index,
1905
return hpi_control_param_set(h_control, HPI_COMPANDER_DECAY, decay,
1909
u16 hpi_compander_get_decay_time_constant(u32 h_control, unsigned int index,
1912
return hpi_control_param_get(h_control, HPI_COMPANDER_DECAY, 0, index,
1917
u16 hpi_compander_set_threshold(u32 h_control, unsigned int index,
1918
short threshold0_01dB)
2203
1920
struct hpi_message hm;
2204
1921
struct hpi_response hr;
2206
1923
hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2207
1924
HPI_CONTROL_SET_STATE);
2208
u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
1925
if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
1926
return HPI_ERROR_INVALID_HANDLE;
2209
1927
hm.u.c.attribute = HPI_COMPANDER_THRESHOLD;
2210
1928
hm.u.c.param2 = index;
2211
1929
hm.u.c.an_log_value[0] = threshold0_01dB;
2555
2264
return hr.error;
2558
u16 hpi_sample_clock_query_source(const struct hpi_hsubsys *ph_subsys,
2559
const u32 h_clock, const u32 index, u16 *pw_source)
2267
u16 hpi_sample_clock_query_source(const u32 h_clock, const u32 index,
2564
err = hpi_control_query(ph_subsys, h_clock, HPI_SAMPLECLOCK_SOURCE,
2273
err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE, index, 0,
2566
2275
*pw_source = (u16)qr;
2570
u16 hpi_sample_clock_set_source(const struct hpi_hsubsys *ph_subsys,
2571
u32 h_control, u16 source)
2279
u16 hpi_sample_clock_set_source(u32 h_control, u16 source)
2573
return hpi_control_param_set(ph_subsys, h_control,
2574
HPI_SAMPLECLOCK_SOURCE, source, 0);
2281
return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE,
2577
u16 hpi_sample_clock_get_source(const struct hpi_hsubsys *ph_subsys,
2578
u32 h_control, u16 *pw_source)
2285
u16 hpi_sample_clock_get_source(u32 h_control, u16 *pw_source)
2581
2288
u32 source = 0;
2582
error = hpi_control_param1_get(ph_subsys, h_control,
2583
HPI_SAMPLECLOCK_SOURCE, &source);
2289
err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE,
2586
2293
*pw_source = (u16)source;
2590
u16 hpi_sample_clock_query_source_index(const struct hpi_hsubsys *ph_subsys,
2591
const u32 h_clock, const u32 index, const u32 source,
2592
u16 *pw_source_index)
2297
u16 hpi_sample_clock_query_source_index(const u32 h_clock, const u32 index,
2298
const u32 source, u16 *pw_source_index)
2597
err = hpi_control_query(ph_subsys, h_clock,
2598
HPI_SAMPLECLOCK_SOURCE_INDEX, index, source, &qr);
2303
err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_SOURCE_INDEX, index,
2599
2305
*pw_source_index = (u16)qr;
2603
u16 hpi_sample_clock_set_source_index(const struct hpi_hsubsys *ph_subsys,
2604
u32 h_control, u16 source_index)
2309
u16 hpi_sample_clock_set_source_index(u32 h_control, u16 source_index)
2606
return hpi_control_param_set(ph_subsys, h_control,
2607
HPI_SAMPLECLOCK_SOURCE_INDEX, source_index, 0);
2311
return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2610
u16 hpi_sample_clock_get_source_index(const struct hpi_hsubsys *ph_subsys,
2611
u32 h_control, u16 *pw_source_index)
2315
u16 hpi_sample_clock_get_source_index(u32 h_control, u16 *pw_source_index)
2614
2318
u32 source_index = 0;
2615
error = hpi_control_param1_get(ph_subsys, h_control,
2616
HPI_SAMPLECLOCK_SOURCE_INDEX, &source_index);
2319
err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SOURCE_INDEX,
2618
2322
if (pw_source_index)
2619
2323
*pw_source_index = (u16)source_index;
2623
u16 hpi_sample_clock_query_local_rate(const struct hpi_hsubsys *ph_subsys,
2624
const u32 h_clock, const u32 index, u32 *prate)
2327
u16 hpi_sample_clock_query_local_rate(const u32 h_clock, const u32 index,
2627
err = hpi_control_query(ph_subsys, h_clock,
2628
HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, index, 0, prate);
2331
err = hpi_control_query(h_clock, HPI_SAMPLECLOCK_LOCAL_SAMPLERATE,
2633
u16 hpi_sample_clock_set_local_rate(const struct hpi_hsubsys *ph_subsys,
2634
u32 h_control, u32 sample_rate)
2337
u16 hpi_sample_clock_set_local_rate(u32 h_control, u32 sample_rate)
2636
return hpi_control_param_set(ph_subsys, h_control,
2339
return hpi_control_param_set(h_control,
2637
2340
HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, sample_rate, 0);
2640
u16 hpi_sample_clock_get_local_rate(const struct hpi_hsubsys *ph_subsys,
2641
u32 h_control, u32 *psample_rate)
2343
u16 hpi_sample_clock_get_local_rate(u32 h_control, u32 *psample_rate)
2644
2346
u32 sample_rate = 0;
2645
error = hpi_control_param1_get(ph_subsys, h_control,
2347
err = hpi_control_param1_get(h_control,
2646
2348
HPI_SAMPLECLOCK_LOCAL_SAMPLERATE, &sample_rate);
2648
2350
if (psample_rate)
2649
2351
*psample_rate = sample_rate;
2653
u16 hpi_sample_clock_get_sample_rate(const struct hpi_hsubsys *ph_subsys,
2654
u32 h_control, u32 *psample_rate)
2355
u16 hpi_sample_clock_get_sample_rate(u32 h_control, u32 *psample_rate)
2657
2358
u32 sample_rate = 0;
2658
error = hpi_control_param1_get(ph_subsys, h_control,
2659
HPI_SAMPLECLOCK_SAMPLERATE, &sample_rate);
2359
err = hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_SAMPLERATE,
2661
2362
if (psample_rate)
2662
2363
*psample_rate = sample_rate;
2666
u16 hpi_sample_clock_set_auto(const struct hpi_hsubsys *ph_subsys,
2667
u32 h_control, u32 enable)
2669
return hpi_control_param_set(ph_subsys, h_control,
2670
HPI_SAMPLECLOCK_AUTO, enable, 0);
2673
u16 hpi_sample_clock_get_auto(const struct hpi_hsubsys *ph_subsys,
2674
u32 h_control, u32 *penable)
2676
return hpi_control_param1_get(ph_subsys, h_control,
2677
HPI_SAMPLECLOCK_AUTO, penable);
2680
u16 hpi_sample_clock_set_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
2681
u32 h_control, u32 lock)
2683
return hpi_control_param_set(ph_subsys, h_control,
2684
HPI_SAMPLECLOCK_LOCAL_LOCK, lock, 0);
2687
u16 hpi_sample_clock_get_local_rate_lock(const struct hpi_hsubsys *ph_subsys,
2688
u32 h_control, u32 *plock)
2690
return hpi_control_param1_get(ph_subsys, h_control,
2691
HPI_SAMPLECLOCK_LOCAL_LOCK, plock);
2694
u16 hpi_tone_detector_get_frequency(const struct hpi_hsubsys *ph_subsys,
2695
u32 h_control, u32 index, u32 *frequency)
2697
return hpi_control_param_get(ph_subsys, h_control,
2698
HPI_TONEDETECTOR_FREQUENCY, index, 0, frequency, NULL);
2701
u16 hpi_tone_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2702
u32 h_control, u32 *state)
2704
return hpi_control_param1_get(ph_subsys, h_control,
2705
HPI_TONEDETECTOR_STATE, state);
2708
u16 hpi_tone_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2709
u32 h_control, u32 enable)
2711
return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2715
u16 hpi_tone_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2716
u32 h_control, u32 *enable)
2718
return hpi_control_param1_get(ph_subsys, h_control,
2719
HPI_GENERIC_ENABLE, enable);
2722
u16 hpi_tone_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2723
u32 h_control, u32 event_enable)
2725
return hpi_control_param_set(ph_subsys, h_control,
2726
HPI_GENERIC_EVENT_ENABLE, (u32)event_enable, 0);
2729
u16 hpi_tone_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2730
u32 h_control, u32 *event_enable)
2732
return hpi_control_param1_get(ph_subsys, h_control,
2733
HPI_GENERIC_EVENT_ENABLE, event_enable);
2736
u16 hpi_tone_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2737
u32 h_control, int threshold)
2739
return hpi_control_param_set(ph_subsys, h_control,
2740
HPI_TONEDETECTOR_THRESHOLD, (u32)threshold, 0);
2743
u16 hpi_tone_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2744
u32 h_control, int *threshold)
2746
return hpi_control_param1_get(ph_subsys, h_control,
2747
HPI_TONEDETECTOR_THRESHOLD, (u32 *)threshold);
2750
u16 hpi_silence_detector_get_state(const struct hpi_hsubsys *ph_subsys,
2751
u32 h_control, u32 *state)
2753
return hpi_control_param1_get(ph_subsys, h_control,
2754
HPI_SILENCEDETECTOR_STATE, state);
2757
u16 hpi_silence_detector_set_enable(const struct hpi_hsubsys *ph_subsys,
2758
u32 h_control, u32 enable)
2760
return hpi_control_param_set(ph_subsys, h_control, HPI_GENERIC_ENABLE,
2764
u16 hpi_silence_detector_get_enable(const struct hpi_hsubsys *ph_subsys,
2765
u32 h_control, u32 *enable)
2767
return hpi_control_param1_get(ph_subsys, h_control,
2768
HPI_GENERIC_ENABLE, enable);
2771
u16 hpi_silence_detector_set_event_enable(const struct hpi_hsubsys *ph_subsys,
2772
u32 h_control, u32 event_enable)
2774
return hpi_control_param_set(ph_subsys, h_control,
2775
HPI_GENERIC_EVENT_ENABLE, event_enable, 0);
2778
u16 hpi_silence_detector_get_event_enable(const struct hpi_hsubsys *ph_subsys,
2779
u32 h_control, u32 *event_enable)
2781
return hpi_control_param1_get(ph_subsys, h_control,
2782
HPI_GENERIC_EVENT_ENABLE, event_enable);
2785
u16 hpi_silence_detector_set_delay(const struct hpi_hsubsys *ph_subsys,
2786
u32 h_control, u32 delay)
2788
return hpi_control_param_set(ph_subsys, h_control,
2789
HPI_SILENCEDETECTOR_DELAY, delay, 0);
2792
u16 hpi_silence_detector_get_delay(const struct hpi_hsubsys *ph_subsys,
2793
u32 h_control, u32 *delay)
2795
return hpi_control_param1_get(ph_subsys, h_control,
2796
HPI_SILENCEDETECTOR_DELAY, delay);
2799
u16 hpi_silence_detector_set_threshold(const struct hpi_hsubsys *ph_subsys,
2800
u32 h_control, int threshold)
2802
return hpi_control_param_set(ph_subsys, h_control,
2803
HPI_SILENCEDETECTOR_THRESHOLD, threshold, 0);
2806
u16 hpi_silence_detector_get_threshold(const struct hpi_hsubsys *ph_subsys,
2807
u32 h_control, int *threshold)
2809
return hpi_control_param1_get(ph_subsys, h_control,
2367
u16 hpi_sample_clock_set_auto(u32 h_control, u32 enable)
2369
return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_AUTO, enable,
2373
u16 hpi_sample_clock_get_auto(u32 h_control, u32 *penable)
2375
return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_AUTO,
2379
u16 hpi_sample_clock_set_local_rate_lock(u32 h_control, u32 lock)
2381
return hpi_control_param_set(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2385
u16 hpi_sample_clock_get_local_rate_lock(u32 h_control, u32 *plock)
2387
return hpi_control_param1_get(h_control, HPI_SAMPLECLOCK_LOCAL_LOCK,
2391
u16 hpi_tone_detector_get_frequency(u32 h_control, u32 index, u32 *frequency)
2393
return hpi_control_param_get(h_control, HPI_TONEDETECTOR_FREQUENCY,
2394
index, 0, frequency, NULL);
2397
u16 hpi_tone_detector_get_state(u32 h_control, u32 *state)
2399
return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_STATE,
2403
u16 hpi_tone_detector_set_enable(u32 h_control, u32 enable)
2405
return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2409
u16 hpi_tone_detector_get_enable(u32 h_control, u32 *enable)
2411
return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2414
u16 hpi_tone_detector_set_event_enable(u32 h_control, u32 event_enable)
2416
return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2417
(u32)event_enable, 0);
2420
u16 hpi_tone_detector_get_event_enable(u32 h_control, u32 *event_enable)
2422
return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2426
u16 hpi_tone_detector_set_threshold(u32 h_control, int threshold)
2428
return hpi_control_param_set(h_control, HPI_TONEDETECTOR_THRESHOLD,
2432
u16 hpi_tone_detector_get_threshold(u32 h_control, int *threshold)
2434
return hpi_control_param1_get(h_control, HPI_TONEDETECTOR_THRESHOLD,
2438
u16 hpi_silence_detector_get_state(u32 h_control, u32 *state)
2440
return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_STATE,
2444
u16 hpi_silence_detector_set_enable(u32 h_control, u32 enable)
2446
return hpi_control_param_set(h_control, HPI_GENERIC_ENABLE, enable,
2450
u16 hpi_silence_detector_get_enable(u32 h_control, u32 *enable)
2452
return hpi_control_param1_get(h_control, HPI_GENERIC_ENABLE, enable);
2455
u16 hpi_silence_detector_set_event_enable(u32 h_control, u32 event_enable)
2457
return hpi_control_param_set(h_control, HPI_GENERIC_EVENT_ENABLE,
2461
u16 hpi_silence_detector_get_event_enable(u32 h_control, u32 *event_enable)
2463
return hpi_control_param1_get(h_control, HPI_GENERIC_EVENT_ENABLE,
2467
u16 hpi_silence_detector_set_delay(u32 h_control, u32 delay)
2469
return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_DELAY,
2473
u16 hpi_silence_detector_get_delay(u32 h_control, u32 *delay)
2475
return hpi_control_param1_get(h_control, HPI_SILENCEDETECTOR_DELAY,
2479
u16 hpi_silence_detector_set_threshold(u32 h_control, int threshold)
2481
return hpi_control_param_set(h_control, HPI_SILENCEDETECTOR_THRESHOLD,
2485
u16 hpi_silence_detector_get_threshold(u32 h_control, int *threshold)
2487
return hpi_control_param1_get(h_control,
2810
2488
HPI_SILENCEDETECTOR_THRESHOLD, (u32 *)threshold);
2813
u16 hpi_tuner_query_band(const struct hpi_hsubsys *ph_subsys,
2814
const u32 h_tuner, const u32 index, u16 *pw_band)
2491
u16 hpi_tuner_query_band(const u32 h_tuner, const u32 index, u16 *pw_band)
2819
err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0,
2496
err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2821
2497
*pw_band = (u16)qr;
2825
u16 hpi_tuner_set_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2501
u16 hpi_tuner_set_band(u32 h_control, u16 band)
2828
return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_BAND,
2503
return hpi_control_param_set(h_control, HPI_TUNER_BAND, band, 0);
2832
u16 hpi_tuner_get_band(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2506
u16 hpi_tuner_get_band(u32 h_control, u16 *pw_band)
2838
error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_BAND,
2511
error = hpi_control_param1_get(h_control, HPI_TUNER_BAND, &band);
2841
2513
*pw_band = (u16)band;
2845
u16 hpi_tuner_query_frequency(const struct hpi_hsubsys *ph_subsys,
2846
const u32 h_tuner, const u32 index, const u16 band, u32 *pfreq)
2848
return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_FREQ, index,
2852
u16 hpi_tuner_set_frequency(const struct hpi_hsubsys *ph_subsys,
2853
u32 h_control, u32 freq_ink_hz)
2855
return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_FREQ,
2859
u16 hpi_tuner_get_frequency(const struct hpi_hsubsys *ph_subsys,
2860
u32 h_control, u32 *pw_freq_ink_hz)
2862
return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_FREQ,
2517
u16 hpi_tuner_query_frequency(const u32 h_tuner, const u32 index,
2518
const u16 band, u32 *pfreq)
2520
return hpi_control_query(h_tuner, HPI_TUNER_FREQ, index, band, pfreq);
2523
u16 hpi_tuner_set_frequency(u32 h_control, u32 freq_ink_hz)
2525
return hpi_control_param_set(h_control, HPI_TUNER_FREQ, freq_ink_hz,
2529
u16 hpi_tuner_get_frequency(u32 h_control, u32 *pw_freq_ink_hz)
2531
return hpi_control_param1_get(h_control, HPI_TUNER_FREQ,
2863
2532
pw_freq_ink_hz);
2866
u16 hpi_tuner_query_gain(const struct hpi_hsubsys *ph_subsys,
2867
const u32 h_tuner, const u32 index, u16 *pw_gain)
2535
u16 hpi_tuner_query_gain(const u32 h_tuner, const u32 index, u16 *pw_gain)
2872
err = hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_BAND, index, 0,
2540
err = hpi_control_query(h_tuner, HPI_TUNER_BAND, index, 0, &qr);
2874
2541
*pw_gain = (u16)qr;
2878
u16 hpi_tuner_set_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2545
u16 hpi_tuner_set_gain(u32 h_control, short gain)
2881
return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_GAIN,
2547
return hpi_control_param_set(h_control, HPI_TUNER_GAIN, gain, 0);
2885
u16 hpi_tuner_get_gain(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2550
u16 hpi_tuner_get_gain(u32 h_control, short *pn_gain)
2891
error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_GAIN,
2555
error = hpi_control_param1_get(h_control, HPI_TUNER_GAIN, &gain);
2894
2557
*pn_gain = (u16)gain;
2898
u16 hpi_tuner_getRF_level(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2901
struct hpi_message hm;
2902
struct hpi_response hr;
2904
hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2905
HPI_CONTROL_GET_STATE);
2906
u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2907
hm.u.c.attribute = HPI_TUNER_LEVEL;
2908
hm.u.c.param1 = HPI_TUNER_LEVEL_AVERAGE;
2909
hpi_send_recv(&hm, &hr);
2911
*pw_level = (short)hr.u.c.param1;
2915
u16 hpi_tuner_get_rawRF_level(const struct hpi_hsubsys *ph_subsys,
2916
u32 h_control, short *pw_level)
2918
struct hpi_message hm;
2919
struct hpi_response hr;
2921
hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2922
HPI_CONTROL_GET_STATE);
2923
u32TOINDEXES(h_control, &hm.adapter_index, &hm.obj_index);
2924
hm.u.c.attribute = HPI_TUNER_LEVEL;
2925
hm.u.c.param1 = HPI_TUNER_LEVEL_RAW;
2926
hpi_send_recv(&hm, &hr);
2928
*pw_level = (short)hr.u.c.param1;
2932
u16 hpi_tuner_query_deemphasis(const struct hpi_hsubsys *ph_subsys,
2933
const u32 h_tuner, const u32 index, const u16 band, u32 *pdeemphasis)
2935
return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_DEEMPHASIS,
2936
index, band, pdeemphasis);
2939
u16 hpi_tuner_set_deemphasis(const struct hpi_hsubsys *ph_subsys,
2940
u32 h_control, u32 deemphasis)
2942
return hpi_control_param_set(ph_subsys, h_control,
2943
HPI_TUNER_DEEMPHASIS, deemphasis, 0);
2946
u16 hpi_tuner_get_deemphasis(const struct hpi_hsubsys *ph_subsys,
2947
u32 h_control, u32 *pdeemphasis)
2949
return hpi_control_param1_get(ph_subsys, h_control,
2950
HPI_TUNER_DEEMPHASIS, pdeemphasis);
2953
u16 hpi_tuner_query_program(const struct hpi_hsubsys *ph_subsys,
2954
const u32 h_tuner, u32 *pbitmap_program)
2956
return hpi_control_query(ph_subsys, h_tuner, HPI_TUNER_PROGRAM, 0, 0,
2561
u16 hpi_tuner_get_rf_level(u32 h_control, short *pw_level)
2563
struct hpi_message hm;
2564
struct hpi_response hr;
2566
hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2567
HPI_CONTROL_GET_STATE);
2568
if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2569
return HPI_ERROR_INVALID_HANDLE;
2570
hm.u.cu.attribute = HPI_TUNER_LEVEL_AVG;
2571
hpi_send_recv(&hm, &hr);
2573
*pw_level = hr.u.cu.tuner.s_level;
2577
u16 hpi_tuner_get_raw_rf_level(u32 h_control, short *pw_level)
2579
struct hpi_message hm;
2580
struct hpi_response hr;
2582
hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL,
2583
HPI_CONTROL_GET_STATE);
2584
if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index))
2585
return HPI_ERROR_INVALID_HANDLE;
2586
hm.u.cu.attribute = HPI_TUNER_LEVEL_RAW;
2587
hpi_send_recv(&hm, &hr);
2589
*pw_level = hr.u.cu.tuner.s_level;
2593
u16 hpi_tuner_query_deemphasis(const u32 h_tuner, const u32 index,
2594
const u16 band, u32 *pdeemphasis)
2596
return hpi_control_query(h_tuner, HPI_TUNER_DEEMPHASIS, index, band,
2600
u16 hpi_tuner_set_deemphasis(u32 h_control, u32 deemphasis)
2602
return hpi_control_param_set(h_control, HPI_TUNER_DEEMPHASIS,
2606
u16 hpi_tuner_get_deemphasis(u32 h_control, u32 *pdeemphasis)
2608
return hpi_control_param1_get(h_control, HPI_TUNER_DEEMPHASIS,
2612
u16 hpi_tuner_query_program(const u32 h_tuner, u32 *pbitmap_program)
2614
return hpi_control_query(h_tuner, HPI_TUNER_PROGRAM, 0, 0,
2957
2615
pbitmap_program);
2960
u16 hpi_tuner_set_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2963
return hpi_control_param_set(ph_subsys, h_control, HPI_TUNER_PROGRAM,
2967
u16 hpi_tuner_get_program(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2970
return hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_PROGRAM,
2974
u16 hpi_tuner_get_hd_radio_dsp_version(const struct hpi_hsubsys *ph_subsys,
2975
u32 h_control, char *psz_dsp_version, const u32 string_size)
2618
u16 hpi_tuner_set_program(u32 h_control, u32 program)
2620
return hpi_control_param_set(h_control, HPI_TUNER_PROGRAM, program,
2624
u16 hpi_tuner_get_program(u32 h_control, u32 *pprogram)
2626
return hpi_control_param1_get(h_control, HPI_TUNER_PROGRAM, pprogram);
2629
u16 hpi_tuner_get_hd_radio_dsp_version(u32 h_control, char *psz_dsp_version,
2630
const u32 string_size)
2977
2632
return hpi_control_get_string(h_control,
2978
2633
HPI_TUNER_HDRADIO_DSP_VERSION, psz_dsp_version, string_size);
2981
u16 hpi_tuner_get_hd_radio_sdk_version(const struct hpi_hsubsys *ph_subsys,
2982
u32 h_control, char *psz_sdk_version, const u32 string_size)
2636
u16 hpi_tuner_get_hd_radio_sdk_version(u32 h_control, char *psz_sdk_version,
2637
const u32 string_size)
2984
2639
return hpi_control_get_string(h_control,
2985
2640
HPI_TUNER_HDRADIO_SDK_VERSION, psz_sdk_version, string_size);
2988
u16 hpi_tuner_get_status(const struct hpi_hsubsys *ph_subsys, u32 h_control,
2989
u16 *pw_status_mask, u16 *pw_status)
2643
u16 hpi_tuner_get_status(u32 h_control, u16 *pw_status_mask, u16 *pw_status)
2991
2645
u32 status = 0;
2994
error = hpi_control_param1_get(ph_subsys, h_control, HPI_TUNER_STATUS,
2648
error = hpi_control_param1_get(h_control, HPI_TUNER_STATUS, &status);
2996
2649
if (pw_status) {
2998
2651
*pw_status_mask = (u16)(status >> 16);
3214
2864
return hr.error;
3217
static size_t strv_packet_size = MIN_STRV_PACKET_SIZE;
3219
static size_t entity_type_to_size[LAST_ENTITY_TYPE] = {
3221
sizeof(struct hpi_entity),
3236
static inline size_t hpi_entity_size(struct hpi_entity *entity_ptr)
3238
return entity_ptr->header.size;
3241
static inline size_t hpi_entity_header_size(struct hpi_entity *entity_ptr)
3243
return sizeof(entity_ptr->header);
3246
static inline size_t hpi_entity_value_size(struct hpi_entity *entity_ptr)
3248
return hpi_entity_size(entity_ptr) -
3249
hpi_entity_header_size(entity_ptr);
3252
static inline size_t hpi_entity_item_count(struct hpi_entity *entity_ptr)
3254
return hpi_entity_value_size(entity_ptr) /
3255
entity_type_to_size[entity_ptr->header.type];
3258
static inline struct hpi_entity *hpi_entity_ptr_to_next(struct hpi_entity
3261
return (void *)(((u8 *)entity_ptr) + hpi_entity_size(entity_ptr));
3264
static inline u16 hpi_entity_check_type(const enum e_entity_type t)
3266
if (t >= 0 && t < STR_TYPE_FIELD_MAX)
3268
return HPI_ERROR_ENTITY_TYPE_INVALID;
3271
static inline u16 hpi_entity_check_role(const enum e_entity_role r)
3273
if (r >= 0 && r < STR_ROLE_FIELD_MAX)
3275
return HPI_ERROR_ENTITY_ROLE_INVALID;
3278
static u16 hpi_entity_get_next(struct hpi_entity *entity, int recursive_flag,
3279
void *guard_p, struct hpi_entity **next)
3281
HPI_DEBUG_ASSERT(entity != NULL);
3282
HPI_DEBUG_ASSERT(next != NULL);
3283
HPI_DEBUG_ASSERT(hpi_entity_size(entity) != 0);
3285
if (guard_p <= (void *)entity) {
3290
if (recursive_flag && entity->header.type == entity_type_sequence)
3291
*next = (struct hpi_entity *)entity->value;
3293
*next = (struct hpi_entity *)hpi_entity_ptr_to_next(entity);
3295
if (guard_p <= (void *)*next) {
3300
HPI_DEBUG_ASSERT(guard_p >= (void *)hpi_entity_ptr_to_next(*next));
3304
u16 hpi_entity_find_next(struct hpi_entity *container_entity,
3305
enum e_entity_type type, enum e_entity_role role, int recursive_flag,
3306
struct hpi_entity **current_match)
3308
struct hpi_entity *tmp = NULL;
3309
void *guard_p = NULL;
3311
HPI_DEBUG_ASSERT(container_entity != NULL);
3312
guard_p = hpi_entity_ptr_to_next(container_entity);
3314
if (*current_match != NULL)
3315
hpi_entity_get_next(*current_match, recursive_flag, guard_p,
3318
hpi_entity_get_next(container_entity, 1, guard_p, &tmp);
3323
HPI_DEBUG_ASSERT((void *)tmp >= (void *)container_entity);
3325
if ((!type || tmp->header.type == type) && (!role
3326
|| tmp->header.role == role)) {
3327
*current_match = tmp;
3331
err = hpi_entity_get_next(tmp, recursive_flag, guard_p,
3336
tmp = *current_match;
3339
*current_match = NULL;
3343
void hpi_entity_free(struct hpi_entity *entity)
3348
static u16 hpi_entity_alloc_and_copy(struct hpi_entity *src,
3349
struct hpi_entity **dst)
3352
HPI_DEBUG_ASSERT(dst != NULL);
3353
HPI_DEBUG_ASSERT(src != NULL);
3355
buf_size = hpi_entity_size(src);
3356
*dst = kmalloc(buf_size, GFP_KERNEL);
3358
return HPI_ERROR_MEMORY_ALLOC;
3359
memcpy(*dst, src, buf_size);
3363
u16 hpi_universal_info(const struct hpi_hsubsys *ph_subsys, u32 hC,
3364
struct hpi_entity **info)
3366
struct hpi_msg_strv hm;
3367
struct hpi_res_strv *phr;
3369
int remaining_attempts = 2;
3370
size_t resp_packet_size = 1024;
3374
while (remaining_attempts--) {
3375
phr = kmalloc(resp_packet_size, GFP_KERNEL);
3376
HPI_DEBUG_ASSERT(phr != NULL);
3378
hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3379
(u16)resp_packet_size, HPI_OBJ_CONTROL,
3380
HPI_CONTROL_GET_INFO);
3381
u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3383
hm.strv.header.size = sizeof(hm.strv);
3384
phr->strv.header.size = resp_packet_size - sizeof(phr->h);
3386
hpi_send_recv((struct hpi_message *)&hm.h,
3387
(struct hpi_response *)&phr->h);
3388
if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3390
HPI_DEBUG_ASSERT(phr->h.specific_error >
3391
MIN_STRV_PACKET_SIZE
3392
&& phr->h.specific_error < 1500);
3393
resp_packet_size = phr->h.specific_error;
3395
remaining_attempts = 0;
3397
hpi_entity_alloc_and_copy(&phr->strv, info);
3400
hpi_err = phr->h.error;
3407
u16 hpi_universal_get(const struct hpi_hsubsys *ph_subsys, u32 hC,
3408
struct hpi_entity **value)
3410
struct hpi_msg_strv hm;
3411
struct hpi_res_strv *phr;
3413
int remaining_attempts = 2;
3417
while (remaining_attempts--) {
3418
phr = kmalloc(strv_packet_size, GFP_KERNEL);
3420
return HPI_ERROR_MEMORY_ALLOC;
3422
hpi_init_message_responseV1(&hm.h, (u16)sizeof(hm), &phr->h,
3423
(u16)strv_packet_size, HPI_OBJ_CONTROL,
3424
HPI_CONTROL_GET_STATE);
3425
u32TOINDEXES(hC, &hm.h.adapter_index, &hm.h.obj_index);
3427
hm.strv.header.size = sizeof(hm.strv);
3428
phr->strv.header.size = strv_packet_size - sizeof(phr->h);
3430
hpi_send_recv((struct hpi_message *)&hm.h,
3431
(struct hpi_response *)&phr->h);
3432
if (phr->h.error == HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL) {
3434
HPI_DEBUG_ASSERT(phr->h.specific_error >
3435
MIN_STRV_PACKET_SIZE
3436
&& phr->h.specific_error < 1000);
3437
strv_packet_size = phr->h.specific_error;
3439
remaining_attempts = 0;
3441
hpi_entity_alloc_and_copy(&phr->strv, value);
3444
hpi_err = phr->h.error;
3451
u16 hpi_universal_set(const struct hpi_hsubsys *ph_subsys, u32 hC,
3452
struct hpi_entity *value)
3454
struct hpi_msg_strv *phm;
3455
struct hpi_res_strv hr;
3457
phm = kmalloc(sizeof(phm->h) + value->header.size, GFP_KERNEL);
3458
HPI_DEBUG_ASSERT(phm != NULL);
3460
hpi_init_message_responseV1(&phm->h,
3461
sizeof(phm->h) + value->header.size, &hr.h, sizeof(hr),
3462
HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE);
3463
u32TOINDEXES(hC, &phm->h.adapter_index, &phm->h.obj_index);
3464
hr.strv.header.size = sizeof(hr.strv);
3466
memcpy(&phm->strv, value, value->header.size);
3467
hpi_send_recv((struct hpi_message *)&phm->h,
3468
(struct hpi_response *)&hr.h);
3473
u16 hpi_entity_alloc_and_pack(const enum e_entity_type type,
3474
const size_t item_count, const enum e_entity_role role, void *value,
3475
struct hpi_entity **entity)
3477
size_t bytes_to_copy, total_size;
3481
hE = hpi_entity_check_type(type);
3485
HPI_DEBUG_ASSERT(role > entity_role_null && type < LAST_ENTITY_TYPE);
3487
bytes_to_copy = entity_type_to_size[type] * item_count;
3488
total_size = hpi_entity_header_size(*entity) + bytes_to_copy;
3490
HPI_DEBUG_ASSERT(total_size >= hpi_entity_header_size(*entity)
3491
&& total_size < STR_SIZE_FIELD_MAX);
3493
*entity = kmalloc(total_size, GFP_KERNEL);
3494
if (*entity == NULL)
3495
return HPI_ERROR_MEMORY_ALLOC;
3496
memcpy((*entity)->value, value, bytes_to_copy);
3497
(*entity)->header.size =
3498
hpi_entity_header_size(*entity) + bytes_to_copy;
3499
(*entity)->header.type = type;
3500
(*entity)->header.role = role;
3504
u16 hpi_entity_copy_value_from(struct hpi_entity *entity,
3505
enum e_entity_type type, size_t item_count, void *value_dst_p)
3507
size_t bytes_to_copy;
3509
if (entity->header.type != type)
3510
return HPI_ERROR_ENTITY_TYPE_MISMATCH;
3512
if (hpi_entity_item_count(entity) != item_count)
3513
return HPI_ERROR_ENTITY_ITEM_COUNT;
3515
bytes_to_copy = entity_type_to_size[type] * item_count;
3516
memcpy(value_dst_p, entity->value, bytes_to_copy);
3520
u16 hpi_entity_unpack(struct hpi_entity *entity, enum e_entity_type *type,
3521
size_t *item_count, enum e_entity_role *role, void **value)
3524
HPI_DEBUG_ASSERT(entity != NULL);
3527
*type = entity->header.type;
3530
*role = entity->header.role;
3533
*value = entity->value;
3535
if (item_count != NULL) {
3536
if (entity->header.type == entity_type_sequence) {
3537
void *guard_p = hpi_entity_ptr_to_next(entity);
3538
struct hpi_entity *next = NULL;
3539
void *contents = entity->value;
3542
while (contents < guard_p) {
3544
err = hpi_entity_get_next(contents, 0,
3546
if (next == NULL || err)
3551
*item_count = hpi_entity_item_count(entity);
3557
u16 hpi_gpio_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3558
u32 *ph_gpio, u16 *pw_number_input_bits, u16 *pw_number_output_bits)
3560
struct hpi_message hm;
3561
struct hpi_response hr;
3562
hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_OPEN);
3563
hm.adapter_index = adapter_index;
3565
hpi_send_recv(&hm, &hr);
3567
if (hr.error == 0) {
3569
hpi_indexes_to_handle(HPI_OBJ_GPIO, adapter_index, 0);
3570
if (pw_number_input_bits)
3571
*pw_number_input_bits = hr.u.l.number_input_bits;
3572
if (pw_number_output_bits)
3573
*pw_number_output_bits = hr.u.l.number_output_bits;
3579
u16 hpi_gpio_read_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3580
u16 bit_index, u16 *pw_bit_data)
3582
struct hpi_message hm;
3583
struct hpi_response hr;
3584
hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_BIT);
3585
u32TOINDEX(h_gpio, &hm.adapter_index);
3586
hm.u.l.bit_index = bit_index;
3588
hpi_send_recv(&hm, &hr);
3590
*pw_bit_data = hr.u.l.bit_data[0];
3594
u16 hpi_gpio_read_all_bits(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3595
u16 aw_all_bit_data[4]
3598
struct hpi_message hm;
3599
struct hpi_response hr;
3600
hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_READ_ALL);
3601
u32TOINDEX(h_gpio, &hm.adapter_index);
3603
hpi_send_recv(&hm, &hr);
3605
if (aw_all_bit_data) {
3606
aw_all_bit_data[0] = hr.u.l.bit_data[0];
3607
aw_all_bit_data[1] = hr.u.l.bit_data[1];
3608
aw_all_bit_data[2] = hr.u.l.bit_data[2];
3609
aw_all_bit_data[3] = hr.u.l.bit_data[3];
3614
u16 hpi_gpio_write_bit(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3615
u16 bit_index, u16 bit_data)
3617
struct hpi_message hm;
3618
struct hpi_response hr;
3619
hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO, HPI_GPIO_WRITE_BIT);
3620
u32TOINDEX(h_gpio, &hm.adapter_index);
3621
hm.u.l.bit_index = bit_index;
3622
hm.u.l.bit_data = bit_data;
3624
hpi_send_recv(&hm, &hr);
3629
u16 hpi_gpio_write_status(const struct hpi_hsubsys *ph_subsys, u32 h_gpio,
3630
u16 aw_all_bit_data[4]
3633
struct hpi_message hm;
3634
struct hpi_response hr;
3635
hpi_init_message_response(&hm, &hr, HPI_OBJ_GPIO,
3636
HPI_GPIO_WRITE_STATUS);
3637
u32TOINDEX(h_gpio, &hm.adapter_index);
3639
hpi_send_recv(&hm, &hr);
3641
if (aw_all_bit_data) {
3642
aw_all_bit_data[0] = hr.u.l.bit_data[0];
3643
aw_all_bit_data[1] = hr.u.l.bit_data[1];
3644
aw_all_bit_data[2] = hr.u.l.bit_data[2];
3645
aw_all_bit_data[3] = hr.u.l.bit_data[3];
3650
u16 hpi_async_event_open(const struct hpi_hsubsys *ph_subsys,
3651
u16 adapter_index, u32 *ph_async)
3653
struct hpi_message hm;
3654
struct hpi_response hr;
3655
hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3656
HPI_ASYNCEVENT_OPEN);
3657
hm.adapter_index = adapter_index;
3659
hpi_send_recv(&hm, &hr);
3664
hpi_indexes_to_handle(HPI_OBJ_ASYNCEVENT,
3672
u16 hpi_async_event_close(const struct hpi_hsubsys *ph_subsys, u32 h_async)
3674
struct hpi_message hm;
3675
struct hpi_response hr;
3676
hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3677
HPI_ASYNCEVENT_OPEN);
3678
u32TOINDEX(h_async, &hm.adapter_index);
3680
hpi_send_recv(&hm, &hr);
3685
u16 hpi_async_event_wait(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3686
u16 maximum_events, struct hpi_async_event *p_events,
3687
u16 *pw_number_returned)
3693
u16 hpi_async_event_get_count(const struct hpi_hsubsys *ph_subsys,
3694
u32 h_async, u16 *pw_count)
3696
struct hpi_message hm;
3697
struct hpi_response hr;
3698
hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3699
HPI_ASYNCEVENT_GETCOUNT);
3700
u32TOINDEX(h_async, &hm.adapter_index);
3702
hpi_send_recv(&hm, &hr);
3706
*pw_count = hr.u.as.u.count.count;
3711
u16 hpi_async_event_get(const struct hpi_hsubsys *ph_subsys, u32 h_async,
3712
u16 maximum_events, struct hpi_async_event *p_events,
3713
u16 *pw_number_returned)
3715
struct hpi_message hm;
3716
struct hpi_response hr;
3717
hpi_init_message_response(&hm, &hr, HPI_OBJ_ASYNCEVENT,
3718
HPI_ASYNCEVENT_GET);
3719
u32TOINDEX(h_async, &hm.adapter_index);
3721
hpi_send_recv(&hm, &hr);
3723
memcpy(p_events, &hr.u.as.u.event,
3724
sizeof(struct hpi_async_event));
3725
*pw_number_returned = 1;
3731
u16 hpi_nv_memory_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3732
u32 *ph_nv_memory, u16 *pw_size_in_bytes)
3734
struct hpi_message hm;
3735
struct hpi_response hr;
3736
hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3738
hm.adapter_index = adapter_index;
3740
hpi_send_recv(&hm, &hr);
3742
if (hr.error == 0) {
3744
hpi_indexes_to_handle(HPI_OBJ_NVMEMORY, adapter_index,
3746
if (pw_size_in_bytes)
3747
*pw_size_in_bytes = hr.u.n.size_in_bytes;
3753
u16 hpi_nv_memory_read_byte(const struct hpi_hsubsys *ph_subsys,
3754
u32 h_nv_memory, u16 index, u16 *pw_data)
3756
struct hpi_message hm;
3757
struct hpi_response hr;
3758
hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3759
HPI_NVMEMORY_READ_BYTE);
3760
u32TOINDEX(h_nv_memory, &hm.adapter_index);
3761
hm.u.n.address = index;
3763
hpi_send_recv(&hm, &hr);
3765
*pw_data = hr.u.n.data;
3769
u16 hpi_nv_memory_write_byte(const struct hpi_hsubsys *ph_subsys,
3770
u32 h_nv_memory, u16 index, u16 data)
3772
struct hpi_message hm;
3773
struct hpi_response hr;
3774
hpi_init_message_response(&hm, &hr, HPI_OBJ_NVMEMORY,
3775
HPI_NVMEMORY_WRITE_BYTE);
3776
u32TOINDEX(h_nv_memory, &hm.adapter_index);
3777
hm.u.n.address = index;
3780
hpi_send_recv(&hm, &hr);
3785
u16 hpi_profile_open_all(const struct hpi_hsubsys *ph_subsys,
3786
u16 adapter_index, u16 profile_index, u32 *ph_profile,
3787
u16 *pw_max_profiles)
3789
struct hpi_message hm;
3790
struct hpi_response hr;
3791
hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3792
HPI_PROFILE_OPEN_ALL);
3793
hm.adapter_index = adapter_index;
3794
hm.obj_index = profile_index;
3795
hpi_send_recv(&hm, &hr);
3797
*pw_max_profiles = hr.u.p.u.o.max_profiles;
3800
hpi_indexes_to_handle(HPI_OBJ_PROFILE, adapter_index,
3807
u16 hpi_profile_get(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3808
u16 bin_index, u16 *pw_seconds, u32 *pmicro_seconds, u32 *pcall_count,
3809
u32 *pmax_micro_seconds, u32 *pmin_micro_seconds)
3811
struct hpi_message hm;
3812
struct hpi_response hr;
3813
hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE, HPI_PROFILE_GET);
3814
u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3815
hm.u.p.bin_index = bin_index;
3816
hpi_send_recv(&hm, &hr);
3818
*pw_seconds = hr.u.p.u.t.seconds;
3820
*pmicro_seconds = hr.u.p.u.t.micro_seconds;
3822
*pcall_count = hr.u.p.u.t.call_count;
3823
if (pmax_micro_seconds)
3824
*pmax_micro_seconds = hr.u.p.u.t.max_micro_seconds;
3825
if (pmin_micro_seconds)
3826
*pmin_micro_seconds = hr.u.p.u.t.min_micro_seconds;
3830
u16 hpi_profile_get_utilization(const struct hpi_hsubsys *ph_subsys,
3831
u32 h_profile, u32 *putilization)
3833
struct hpi_message hm;
3834
struct hpi_response hr;
3835
hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3836
HPI_PROFILE_GET_UTILIZATION);
3837
u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3838
hpi_send_recv(&hm, &hr);
3844
*putilization = hr.u.p.u.t.call_count;
3849
u16 hpi_profile_get_name(const struct hpi_hsubsys *ph_subsys, u32 h_profile,
3850
u16 bin_index, char *sz_name, u16 name_length)
3852
struct hpi_message hm;
3853
struct hpi_response hr;
3854
hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3855
HPI_PROFILE_GET_NAME);
3856
u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3857
hm.u.p.bin_index = bin_index;
3858
hpi_send_recv(&hm, &hr);
3861
strcpy(sz_name, "??");
3864
memcpy(sz_name, (char *)hr.u.p.u.n.sz_name,
3870
u16 hpi_profile_start_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3872
struct hpi_message hm;
3873
struct hpi_response hr;
3874
hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3875
HPI_PROFILE_START_ALL);
3876
u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3877
hpi_send_recv(&hm, &hr);
3882
u16 hpi_profile_stop_all(const struct hpi_hsubsys *ph_subsys, u32 h_profile)
3884
struct hpi_message hm;
3885
struct hpi_response hr;
3886
hpi_init_message_response(&hm, &hr, HPI_OBJ_PROFILE,
3887
HPI_PROFILE_STOP_ALL);
3888
u32TOINDEXES(h_profile, &hm.adapter_index, &hm.obj_index);
3889
hpi_send_recv(&hm, &hr);
3894
u16 hpi_watchdog_open(const struct hpi_hsubsys *ph_subsys, u16 adapter_index,
3897
struct hpi_message hm;
3898
struct hpi_response hr;
3899
hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3901
hm.adapter_index = adapter_index;
3903
hpi_send_recv(&hm, &hr);
3907
hpi_indexes_to_handle(HPI_OBJ_WATCHDOG, adapter_index,
3914
u16 hpi_watchdog_set_time(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog,
3917
struct hpi_message hm;
3918
struct hpi_response hr;
3919
hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3920
HPI_WATCHDOG_SET_TIME);
3921
u32TOINDEX(h_watchdog, &hm.adapter_index);
3922
hm.u.w.time_ms = time_millisec;
3924
hpi_send_recv(&hm, &hr);
3929
u16 hpi_watchdog_ping(const struct hpi_hsubsys *ph_subsys, u32 h_watchdog)
3931
struct hpi_message hm;
3932
struct hpi_response hr;
3933
hpi_init_message_response(&hm, &hr, HPI_OBJ_WATCHDOG,
3935
u32TOINDEX(h_watchdog, &hm.adapter_index);
3937
hpi_send_recv(&hm, &hr);