diff options
Diffstat (limited to 'sound/pci/asihpi/hpifunc.c')
| -rw-r--r-- | sound/pci/asihpi/hpifunc.c | 86 |
1 files changed, 41 insertions, 45 deletions
diff --git a/sound/pci/asihpi/hpifunc.c b/sound/pci/asihpi/hpifunc.c index 7397b169b89f..ebb568d695f1 100644 --- a/sound/pci/asihpi/hpifunc.c +++ b/sound/pci/asihpi/hpifunc.c | |||
| @@ -1663,68 +1663,64 @@ u16 hpi_channel_mode_get(u32 h_control, u16 *mode) | |||
| 1663 | u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count, | 1663 | u16 hpi_cobranet_hmi_write(u32 h_control, u32 hmi_address, u32 byte_count, |
| 1664 | u8 *pb_data) | 1664 | u8 *pb_data) |
| 1665 | { | 1665 | { |
| 1666 | struct hpi_message hm; | 1666 | struct hpi_msg_cobranet_hmiwrite hm; |
| 1667 | struct hpi_response hr; | 1667 | struct hpi_response_header hr; |
| 1668 | 1668 | ||
| 1669 | hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, | 1669 | hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr, sizeof(hr), |
| 1670 | HPI_CONTROL_SET_STATE); | 1670 | HPI_OBJ_CONTROL, HPI_CONTROL_SET_STATE); |
| 1671 | if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index)) | ||
| 1672 | return HPI_ERROR_INVALID_HANDLE; | ||
| 1673 | 1671 | ||
| 1674 | hm.u.cx.u.cobranet_data.byte_count = byte_count; | 1672 | if (hpi_handle_indexes(h_control, &hm.h.adapter_index, |
| 1675 | hm.u.cx.u.cobranet_data.hmi_address = hmi_address; | 1673 | &hm.h.obj_index)) |
| 1674 | return HPI_ERROR_INVALID_HANDLE; | ||
| 1676 | 1675 | ||
| 1677 | if (byte_count <= 8) { | 1676 | if (byte_count > sizeof(hm.bytes)) |
| 1678 | memcpy(hm.u.cx.u.cobranet_data.data, pb_data, byte_count); | 1677 | return HPI_ERROR_MESSAGE_BUFFER_TOO_SMALL; |
| 1679 | hm.u.cx.attribute = HPI_COBRANET_SET; | ||
| 1680 | } else { | ||
| 1681 | hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; | ||
| 1682 | hm.u.cx.attribute = HPI_COBRANET_SET_DATA; | ||
| 1683 | } | ||
| 1684 | 1678 | ||
| 1685 | hpi_send_recv(&hm, &hr); | 1679 | hm.p.attribute = HPI_COBRANET_SET; |
| 1680 | hm.p.byte_count = byte_count; | ||
| 1681 | hm.p.hmi_address = hmi_address; | ||
| 1682 | memcpy(hm.bytes, pb_data, byte_count); | ||
| 1683 | hm.h.size = (u16)(sizeof(hm.h) + sizeof(hm.p) + byte_count); | ||
| 1686 | 1684 | ||
| 1685 | hpi_send_recvV1(&hm.h, &hr); | ||
| 1687 | return hr.error; | 1686 | return hr.error; |
| 1688 | } | 1687 | } |
| 1689 | 1688 | ||
| 1690 | u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count, | 1689 | u16 hpi_cobranet_hmi_read(u32 h_control, u32 hmi_address, u32 max_byte_count, |
| 1691 | u32 *pbyte_count, u8 *pb_data) | 1690 | u32 *pbyte_count, u8 *pb_data) |
| 1692 | { | 1691 | { |
| 1693 | struct hpi_message hm; | 1692 | struct hpi_msg_cobranet_hmiread hm; |
| 1694 | struct hpi_response hr; | 1693 | struct hpi_res_cobranet_hmiread hr; |
| 1695 | 1694 | ||
| 1696 | hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, | 1695 | hpi_init_message_responseV1(&hm.h, sizeof(hm), &hr.h, sizeof(hr), |
| 1697 | HPI_CONTROL_GET_STATE); | 1696 | HPI_OBJ_CONTROL, HPI_CONTROL_GET_STATE); |
| 1698 | if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index)) | 1697 | |
| 1698 | if (hpi_handle_indexes(h_control, &hm.h.adapter_index, | ||
| 1699 | &hm.h.obj_index)) | ||
| 1699 | return HPI_ERROR_INVALID_HANDLE; | 1700 | return HPI_ERROR_INVALID_HANDLE; |
| 1700 | 1701 | ||
| 1701 | hm.u.cx.u.cobranet_data.byte_count = max_byte_count; | 1702 | if (max_byte_count > sizeof(hr.bytes)) |
| 1702 | hm.u.cx.u.cobranet_data.hmi_address = hmi_address; | 1703 | return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; |
| 1703 | 1704 | ||
| 1704 | if (max_byte_count <= 8) { | 1705 | hm.p.attribute = HPI_COBRANET_GET; |
| 1705 | hm.u.cx.attribute = HPI_COBRANET_GET; | 1706 | hm.p.byte_count = max_byte_count; |
| 1706 | } else { | 1707 | hm.p.hmi_address = hmi_address; |
| 1707 | hm.u.cx.u.cobranet_bigdata.pb_data = pb_data; | ||
| 1708 | hm.u.cx.attribute = HPI_COBRANET_GET_DATA; | ||
| 1709 | } | ||
| 1710 | 1708 | ||
| 1711 | hpi_send_recv(&hm, &hr); | 1709 | hpi_send_recvV1(&hm.h, &hr.h); |
| 1712 | if (!hr.error && pb_data) { | ||
| 1713 | 1710 | ||
| 1714 | *pbyte_count = hr.u.cx.u.cobranet_data.byte_count; | 1711 | if (!hr.h.error && pb_data) { |
| 1712 | if (hr.byte_count > sizeof(hr.bytes)) | ||
| 1715 | 1713 | ||
| 1716 | if (*pbyte_count < max_byte_count) | 1714 | return HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL; |
| 1717 | max_byte_count = *pbyte_count; | ||
| 1718 | 1715 | ||
| 1719 | if (hm.u.cx.attribute == HPI_COBRANET_GET) { | 1716 | *pbyte_count = hr.byte_count; |
| 1720 | memcpy(pb_data, hr.u.cx.u.cobranet_data.data, | ||
| 1721 | max_byte_count); | ||
| 1722 | } else { | ||
| 1723 | 1717 | ||
| 1724 | } | 1718 | if (hr.byte_count < max_byte_count) |
| 1719 | max_byte_count = *pbyte_count; | ||
| 1725 | 1720 | ||
| 1721 | memcpy(pb_data, hr.bytes, max_byte_count); | ||
| 1726 | } | 1722 | } |
| 1727 | return hr.error; | 1723 | return hr.h.error; |
| 1728 | } | 1724 | } |
| 1729 | 1725 | ||
| 1730 | u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus, | 1726 | u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus, |
| @@ -1733,23 +1729,23 @@ u16 hpi_cobranet_hmi_get_status(u32 h_control, u32 *pstatus, | |||
| 1733 | struct hpi_message hm; | 1729 | struct hpi_message hm; |
| 1734 | struct hpi_response hr; | 1730 | struct hpi_response hr; |
| 1735 | 1731 | ||
| 1736 | hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROLEX, | 1732 | hpi_init_message_response(&hm, &hr, HPI_OBJ_CONTROL, |
| 1737 | HPI_CONTROL_GET_STATE); | 1733 | HPI_CONTROL_GET_STATE); |
| 1738 | if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index)) | 1734 | if (hpi_handle_indexes(h_control, &hm.adapter_index, &hm.obj_index)) |
| 1739 | return HPI_ERROR_INVALID_HANDLE; | 1735 | return HPI_ERROR_INVALID_HANDLE; |
| 1740 | 1736 | ||
| 1741 | hm.u.cx.attribute = HPI_COBRANET_GET_STATUS; | 1737 | hm.u.c.attribute = HPI_COBRANET_GET_STATUS; |
| 1742 | 1738 | ||
| 1743 | hpi_send_recv(&hm, &hr); | 1739 | hpi_send_recv(&hm, &hr); |
| 1744 | if (!hr.error) { | 1740 | if (!hr.error) { |
| 1745 | if (pstatus) | 1741 | if (pstatus) |
| 1746 | *pstatus = hr.u.cx.u.cobranet_status.status; | 1742 | *pstatus = hr.u.cu.cobranet.status.status; |
| 1747 | if (preadable_size) | 1743 | if (preadable_size) |
| 1748 | *preadable_size = | 1744 | *preadable_size = |
| 1749 | hr.u.cx.u.cobranet_status.readable_size; | 1745 | hr.u.cu.cobranet.status.readable_size; |
| 1750 | if (pwriteable_size) | 1746 | if (pwriteable_size) |
| 1751 | *pwriteable_size = | 1747 | *pwriteable_size = |
| 1752 | hr.u.cx.u.cobranet_status.writeable_size; | 1748 | hr.u.cu.cobranet.status.writeable_size; |
| 1753 | } | 1749 | } |
| 1754 | return hr.error; | 1750 | return hr.error; |
| 1755 | } | 1751 | } |
