Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux infrastructure fixes. Kernels v4.16+ #5751

Merged
merged 8 commits into from
Feb 3, 2020
11 changes: 8 additions & 3 deletions scripts/patch-realsense-ubuntu-lts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,14 @@ else
patch -p1 < ../scripts/realsense-powerlinefrequency-control-fix.patch
# Applying 3rd-party patch that affects USB2 behavior
# See reference https://patchwork.kernel.org/patch/9907707/
if [ ${k_maj_min} -lt 418 ]; then
echo -e "\e[32mRetrofit uvc bug fix enabled with 4.18+\e[0m"
patch -N -p1 < ../scripts/v1-media-uvcvideo-mark-buffer-error-where-overflow.patch
if [ ${k_maj_min} -lt 418 ];
then
echo -e "\e[32mRetrofit UVC bug fix rectified in 4.18+\e[0m"
if patch -N --dry-run -p1 < ../scripts/v1-media-uvcvideo-mark-buffer-error-where-overflow.patch; then
patch -N -p1 < ../scripts/v1-media-uvcvideo-mark-buffer-error-where-overflow.patch
else
echo -e "\e[36m Skip the patch - it is already found in the source tree\e[0m"
fi
fi
if [ $xhci_patch -eq 1 ]; then
echo -e "\e[32mApplying streamoff hotfix patch in videobuf2-core\e[0m"
Expand Down
19 changes: 9 additions & 10 deletions scripts/patch-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ function require_package {
# master UBUNTU: Ubuntu-4.4.0-128.154 Stefan Bader 4 weeks
# master-next UBUNTU: SAUCE: Redpine: fix soft-ap invisible issue Sanjay Kumar Konduri 2 days

# As of Aug 5th, 2019
# As of Jan 21, 2020
#Ubuntu bionic repo : http://kernel.ubuntu.com/git/ubuntu/ubuntu-bionic.git/
# hwe UBUNTU: Ubuntu-hwe-5.0.0-24.25~18.04.1 Stefan Bader 6 days
# hwe-edge UBUNTU: [Packaging] Support building libperf-jvmti.so Thadeu Lima de Souza Cascardo 2 weeks
# master UBUNTU: Ubuntu-4.15.0-55.60 Kleber Sacilotto de Souza 5 weeks
# 4.18 TAG: Ubuntu-hwe-4.18.0-25.26_18.04.1

# hwe UBUNTU: Ubuntu-hwe-5.3.0-28.30~18.04.1 Sultan Alsawaf 6 days
# hwe-edge UBUNTU: Ubuntu-hwe-edge-5.3.0-24.26~18.04.2 Kleber Sacilotto de Souza 8 weeks
# master UBUNTU: Ubuntu-4.15.0-74.84 Khalid Elmously 5 weeks
# master-current UBUNTU: Ubuntu-4.15.0-66.75 Khalid Elmously 4 months

function choose_kernel_branch {

Expand Down Expand Up @@ -81,14 +80,14 @@ function choose_kernel_branch {
echo Ubuntu-hwe-4.18.0-25.26_18.04.1
;;
"5.0") # kernel 5.0 for Ubuntu 18/Bionic Beaver
echo hwe
echo 5
;;
"5.2") # kernel 5.0 for Ubuntu 18/Bionic Beaver
echo Ubuntu-hwe-edge-5.2.0-9.10_18.04.1
"5.3") # kernel 5.3
echo 5
;;
*)
#error message shall be redirected to stderr to be printed properly
echo -e "\e[31mUnsupported kernel version $1 . The Bionic patches are maintained for Ubuntu LTS with kernels 4.15, 4.18 and 5.0 only\e[0m" >&2
echo -e "\e[31mUnsupported kernel version $1 . The Bionic patches are maintained for Ubuntu LTS with kernels 4.15, 4.18, 5.0 and 5.3\e[0m" >&2
exit 1
;;
esac
Expand Down
156 changes: 98 additions & 58 deletions src/linux/backend-v4l2.cpp

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions src/linux/backend-v4l2.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ namespace librealsense
void set_md_attributes(uint8_t md_size, void* md_start)
{ _md_start = md_start; _md_size = md_size; }
void set_md_from_video_node(bool compressed);
bool verify_vd_md_sync() const;

private:
void* _md_start; // marks the address of metadata blob
Expand All @@ -190,13 +191,23 @@ namespace librealsense
{
if (_data_buf && (!_managed))
{
//LOG_DEBUG("Enqueue buf " << _dq_buf.index << " for fd " << _file_desc);
if ((_file_desc > 0) && (xioctl(_file_desc, (int)VIDIOC_QBUF, &_dq_buf) < 0))
{
LOG_INFO("xioctl(VIDIOC_QBUF) guard failed");
LOG_ERROR("xioctl(VIDIOC_QBUF) guard failed for fd " << std::dec << _file_desc);
if (xioctl(_file_desc, (int)VIDIOC_DQBUF, &_dq_buf) >= 0)
{
LOG_WARNING("xioctl(VIDIOC_QBUF) Re-enqueue succeeded for fd " << std::dec << _file_desc);
if (xioctl(_file_desc, (int)VIDIOC_QBUF, &_dq_buf) < 0)
LOG_WARNING("xioctl(VIDIOC_QBUF) re-deque failed for fd " << std::dec << _file_desc);
else
LOG_WARNING("xioctl(VIDIOC_QBUF) re-deque succeeded for fd " << std::dec << _file_desc);
}
else
LOG_WARNING("xioctl(VIDIOC_QBUF) Re-enqueue failed for fd " << std::dec << _file_desc);
}
}
}

std::shared_ptr<platform::buffer> _data_buf=nullptr;
v4l2_buffer _dq_buf{};
int _file_desc=-1;
Expand Down
5 changes: 3 additions & 2 deletions src/metadata-parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,12 @@ namespace librealsense
double get_fps(const librealsense::frame & frm)
{
// A computation involving unsigned operands can never overflow (ISO/IEC 9899:1999 (E) \A76.2.5/9)
auto num_of_frames = frm.additional_data.frame_number - frm.additional_data.last_frame_number;
// In case of frame counter reset fallback use fps from the stream configuration
auto num_of_frames = (frm.additional_data.frame_number) ? frm.additional_data.frame_number - frm.additional_data.last_frame_number : 0;

if (num_of_frames == 0)
{
LOG_INFO("frame_number - last_frame_number " << num_of_frames);
LOG_INFO("Frame counter reset");
}

auto diff = num_of_frames ? (double)(frm.additional_data.timestamp - frm.additional_data.last_timestamp) / (double)num_of_frames : 0;
Expand Down
4 changes: 2 additions & 2 deletions src/rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1842,8 +1842,8 @@ HANDLE_EXCEPTIONS_AND_RETURN(nullptr, composite)
rs2_frame* rs2_allocate_composite_frame(rs2_source* source, rs2_frame** frames, int count, rs2_error** error) BEGIN_API_CALL
{
VALIDATE_NOT_NULL(source)
VALIDATE_NOT_NULL(frames)
VALIDATE_RANGE(count, 1, 128);
VALIDATE_NOT_NULL(frames)
VALIDATE_RANGE(count, 1, 128);

std::vector<frame_holder> holders(count);
for (int i = 0; i < count; i++)
Expand Down